Home Forums SQL Server 2008 T-SQL (SS2K8) Looking for an elegant way to tranpose my query result RE: Looking for an elegant way to tranpose my query result

  • Jeff Moden (1/19/2015)


    To add to that, you're grouping by the wrong column. You need to group by the BOX TYPE column.

    I am not grouping on the wrong column, each final boxtype contains more than one occurences of individual boxtype.

    I have completed my final script and I am using the same "ugly" way to do it as I think in my case it is the nature of the raw data.

    select 'Server' as BoxType, Sum(s.High) as High, Sum(s.Medium) as Medium,Sum(s.Low) as Low From

    (select .... ) s

    union

    select 'Server' as BoxType, Sum(s.High) as High, Sum(s.Medium) as Medium,Sum(s.Low) as Low From

    (select .... ) s

    union

    select 'Server' as BoxType, Sum(s.High) as High, Sum(s.Medium) as Medium,Sum(s.Low) as Low From

    (select ....) s

    union

    select 'Server' as BoxType, Sum(s.High) as High, Sum(s.Medium) as Medium,Sum(s.Low) as Low From

    (select ....) s

    union

    select 'Server' as BoxType, Sum(s.High) as High, Sum(s.Medium) as Medium,Sum(s.Low) as Low From

    (select ....) s

    Thanks anyway.