Friday, March 9, 2012

how to sum records by month and year

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 date
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
Sufian
See GroupBY and DatePart in BOL. Also you may have better luck with this if
you posted in the Programming section.
"Mohd Sufian" <sufian@.aeroflex.co.th> wrote in message
news:1635C8A0-3859-4D65-8CEE-3F27B0350719@.microsoft.com...
> 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 date
> ----
--
> 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
> Sufian

No comments:

Post a Comment