Lizard
Lizard

Reputation: 45052

mysql count groupings

CREATE TABLE `articles_entities` (
  `id` CHAR(36) NOT NULL,
....
  `created` DATETIME DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `created` (`created`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8;

I am trying to create a query that gives me the count of records by day.. e.g

Day 1: 23 
Day 2: 343 
etc...

Please note the output is not the exact format I want, just a display of what data I want.

Upvotes: 1

Views: 67

Answers (1)

Lizard
Lizard

Reputation: 45052

While writing the question I realised just how easy this is....

SELECT COUNT(*), DATE_FORMAT(created, '%Y%m%d') AS testgroup FROM articles_entities GROUP BY testgroup;

Upvotes: 2

Related Questions