ElDiabolo
ElDiabolo

Reputation: 376

Group by each day

I have the following sql:

SELECT count(TableID) AS Counted, Date
              FROM Table 
                WHERE 1
                  GROUP BY DAY(Date)

The problem is, that I don't want it to be grouped for just every day once (1-31). I want it to be grouped after each day in the year. I want to get my response like:

Counted | Date
2 | 2016-11-15
1 | 2016-11-14
3 | 2016-10-15

Upvotes: 0

Views: 1688

Answers (1)

ElDiabolo
ElDiabolo

Reputation: 376

SELECT count(TableID) AS Counted, Date
              FROM Table 
                WHERE 1
                  GROUP BY year(Date), month(Date), day(Date)

Is the answer. Thanks to @bub.

Upvotes: 1

Related Questions