is this what you want ? If not post your expected resultdeclare @sample table( state varchar(10), qty int)insert into @sampleselect 'Cancelled', 1 union allselect 'Approved', 1 union allselect 'Finished', 1 union allselect 'Implemented', 1 union allselect 'Approved', 2 union allselect 'Finished', 3select state, [total for state] = sum(qty), [total] = sum(sum(qty)) over(), [percentage] = sum(qty) * 100.0 / sum(sum(case when state = 'Approved' then qty else 0 end)) over ()from @samplegroup by state/*state total for state total percentage ---------- --------------- ----------- ---------------------------- Approved 3 9 100.000000000000Cancelled 1 9 33.333333333333Finished 4 9 133.333333333333Implemente 1 9 33.333333333333(4 row(s) affected)*/
KH[spoiler]Time is always against us[/spoiler]