sl1nger
asked on
Select Sum by Day, Month or Year
I'm working on a chart and would like to select the sum of orders on any certain day, month or by a year.
select sum(orders), date_entered from orders where date_entered = getDate() - 365
group by date_entered
select sum(orders), date_entered from orders where date_entered = getDate() - 365
group by date_entered
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
twintai -- I liked yours the best but found these options where more appropriate for sql server
http://support.microsoft.com/kb/186265
Ms for Milliseconds
Yy for Year
Qq for Quarter of the Year
Mm for Month
Dy for the Day of the Year
Dd for Day of the Month
Wk for Week
Dw for the Day of the Week
Hh for Hour
Mi for Minute
Ss for Second
http://support.microsoft.com/kb/186265
Ms for Milliseconds
Yy for Year
Qq for Quarter of the Year
Mm for Month
Dy for the Day of the Year
Dd for Day of the Month
Wk for Week
Dw for the Day of the Week
Hh for Hour
Mi for Minute
Ss for Second
1 important detail: what data type is the field date_entered, and is it containing a time portion?