Link to home
Start Free TrialLog in
Avatar of sl1nger
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
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

can you explain a bit in detail what exactly you have the problem with?
1 important detail: what data type is the field date_entered, and is it containing a time portion?
ASKER CERTIFIED SOLUTION
Avatar of twintai
twintai

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sl1nger
sl1nger

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