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 2005 Forums
 Transact-SQL (2005)
 sql query

Author  Topic 

vijayanto
Starting Member

16 Posts

Posted - 2009-06-02 : 08:20:57
hi friends
i got trouble in sql query
so in the table i have date and quantity fields
so, i want to display the sum of quantity depending on the month of the date
for example : the month april means, in another field i want only the month of april quantities


can anyone reply me
regards
vijay

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-06-02 : 08:26:53
select month(Date), sum(quantities) from urtable group by month(date)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-06-02 : 08:47:56
or

select dateadd(month,datediff(month,0,Date),0), sum(quantities) from urtable group by dateadd(month,datediff(month,0,Date),0)


Madhivanan

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

- Advertisement -