nilesh-652355
SSC Rookie
Points: 29
More actions
March 7, 2011 at 10:36 pm
#233019
I have following table
PKeyProductAprilMayJune
2811600102010
2821601102010
2831602102010
2841600102010
2851601102010
2861602102010
2871600102010
2881601102010
2891602102010
And I want the resuld as belows....
(Sum of April , May and June for each product)
how to write such a query ?
Product April May June
1600 30 60 30
1601 30 60 30
1602 30 60 30
McSQL
SSCarpal Tunnel
Points: 4936
March 8, 2011 at 2:50 am
#1295740
This should do what you're after 🙂
SELECT Product, April, May, June, April+May+June as 'Total'
FROM MYTABLE
ORDER BY Product
Yogesh Potdar
SSC Enthusiast
Points: 192
March 8, 2011 at 2:55 am
#1295742
The same logic will work in case of Int datatype, but in case of Long datatype u need to CAST them while adding in query
Regards, Yog
March 8, 2011 at 2:57 am
#1295745
Thank you !!!
March 8, 2011 at 3:07 am
This was removed by the editor as SPAM
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply