How to get sum of perticuler values from diffrent rows ?

  • 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

  • This should do what you're after 🙂

    SELECT Product, April, May, June, April+May+June as 'Total'

    FROM MYTABLE

    ORDER BY Product

  • 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

  • Thank you !!!

  • 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