all groups > sql server replication > april 2005 >
You're in the

sql server replication

group:

how to sum records by month and year


how to sum records by month and year Mohd Sufian
4/28/2005 1:54:01 AM
sql server replication:
Dear all,
i had a table named saletable i had fields like
itemgroupid,itemgroupname,saleqty,saleamount and saledate.
i want to sum the saleqty and saleamount by every month and year.but i dont
want to eneter the date every time means no user criteria.

for eaxmple
itemgroupid itemgroupname saleqty saleamount dat
--------------------------------------------------------------------------------
23101102 HERO LINER 10.00 50467.29 2004-01-07
23101102 HERO LINER 20.00 10924.58 2005-01-07
23101102 HERO LINER 10.00 50467.29 2004-02-07
23101102 HERO LINER 20.00 10924.58 2005-02-07
23101102 HERO LINER 10.00 50467.29 2004-01-07
23101102 HERO LINER 20.00 10924.58 2005-01-07

23204101 Trading Mudgard 10.00 6000.00 2005-04-21
23204101 Trading Mudgard 10.00 50467.29 2004-01-07
23204101 Trading Mudgard 20.00 10924.58 2005-01-07
23204101 Trading Mudgard 20.00 10924.58 2005-02-07
23204101 Trading Mudgard 10.00 50467.29 2004-01-07
23204101 Trading Mudgard 20.00 10924.58 2005-01-07

I WANT like this
for every month and year
23204101 Trading Mudgard 20.00 100934.58 2004-01
23204101 Trading Mudgard 60.00 2326000.00 2005-01
23204101 Trading Mudgard 10.00 6000.00 2005-07
thanx



--
waiting for solution
from
Re: how to sum records by month and year ChrisR
4/28/2005 6:41:51 AM
See GroupBY and DatePart in BOL. Also you may have better luck with this if
you posted in the Programming section.


[quoted text, click to view]

AddThis Social Bookmark Button