Well your query does work.. Declare @Table Table ( id int, num_avail int, color varchar(10))Insert @Table Select 1,5,'Blue' Union All Select 2,2,'White' Union All Select 3,2,'White'select [AVAILABLE WHITE] = sum(case when color='White' then num_avail end),[AVAILABLE BLUE] = sum(case when color='Blue' then num_avail end),[TOTAL AVAILABLE] = sum(num_avail)from @Table --Output(3 row(s) affected)AVAILABLE WHITE AVAILABLE BLUE TOTAL AVAILABLE--------------- -------------- ---------------4 5 9
Chiraghttp://chirikworld.blogspot.com/