Sep 29, 2014 10:26 PM|Michelle Ge - MSFT|LINK
So far as I know, if you want to display your data as you provided, I think you need two steps.
First, you need to create a temp table, then put the select data below into the temp table:
select PHASE, CODE,Section_id,OPERATION,VALUE,DEP,COST,(DEP+COST) AS Total Cost from tablename
Second, you can get the sum(Value) by the query below:
select '' as PHASE,'' AS CODE, '' AS Section_id,'Total' asOPERATION, sum(VALUE) as value from tempTable
Third, you can union them by the sql query below:
select * from tempTable
Union allselect '' as PHASE,'' AS CODE, '' AS Section_id,'Total' asOPERATION, sum(VALUE) as value from tempTable
Hope it's useful for you.