tsql - Switch SQL result columns to rows and include a summary row beneath -
i'd below columns populate in place of rows , include summary row beneath it:
table1 id name value group 001 bob 100 002 don 200 003 fay 300 b
below example of desired output:
group no sum group 2 300 group b 1 300 total 3 600
select coalesce('group '+ [group], 'total') [group], count([group]) no, sum(value) sum table1 group [group] rollup
Comments
Post a Comment