Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Dates Problem

Author  Topic 

FabioEinaus
Starting Member

41 Posts

Posted - 2006-11-30 : 07:06:22
Hi people!

I have to do a Select the sum of the ValorTotalFactura on every month and on every year and I searched on the forum but I didn't found that information.

Can someone help me?

Cheers!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-30 : 07:15:01
select year(yourdatetimecolumn), month(yourdatetimecolumn), sum(youramountcolumn)
from yourtable group by year(yourdatetimecolumn), month(yourdatetimecolumn)
order by year(yourdatetimecolumn), month(yourdatetimecolumn)

I am amazed Google didn't pick this one up!


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-01 : 03:21:23
>>order by year(yourdatetimecolumn), month(yourdatetimecolumn)

You forget your style

order by 1,2

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -