group by Date

PHOTO EMBED

Thu Mar 14 2024 15:43:46 GMT+0000 (Coordinated Universal Time)

Saved by @darshcode #sql

dateadd(DAY,0, datediff(day,0, created)) will return the day created

for example, if the sale created on '2009-11-02 06:12:55.000', dateadd(DAY,0, datediff(day,0, created)) return '2009-11-02 00:00:00.000'

select sum(amount) as total, dateadd(DAY,0, datediff(day,0, created)) as created
from sales
group by dateadd(DAY,0, datediff(day,0, created))
content_copyCOPY

https://stackoverflow.com/questions/1658340/sql-query-to-group-by-day