I need to get the sum of all column values of a result set in the last row.
Here is my SQL query.
select Master_Code, SUM(Jan), SUM(Feb), SUM(Mar)
from d
Make a union where you repeat the same query but without the grouping:
select Title, Jan, Feb, Mar
from (
select Master_Code as Title, SUM(Jan) as Jan, SUM(Feb) as Feb, SUM(Mar) as Mar
from dbo.foobar
WHERE Participating_City = 'foofoo'
GROUP BY Master_Code ORDER BY Master_Code ASC
) x
union all
select 'Total', SUM(Jan) as Jan, SUM(Feb) as Feb, SUM(Mar) as Mar
from dbo.foobar
WHERE Participating_City = 'foofoo'