RESULT SET NEEDED IN DIFF FORMAT

  • HI

    i have a proc which displays the result as

    CLAIMS CATEGORY

    12345 P1

    42342 P2

    4234234 P3

    but i want the result set to be displayed in this manner

    CLAIMS P1 P2 P3

    12345 x

    42342X

    4234234 x

    so what i should i do.....

    Thanks

  • raghu (3/24/2009)


    HI

    i have a proc which displays the result as

    CLAIMS CATEGORY

    12345 P1

    42342 P2

    4234234 P3

    but i want the result set to be displayed in this manner

    CLAIMS P1 P2 P3

    12345 x

    42342X

    4234234 x

    so what i should i do.....

    Thanks

    Are the categories P1, P2, P3 fixed or are these dynamic?

  • THEY ARE FIXED

  • The following is test code. Look at it and adapt it as needed for your purposes:

    declare @ClaimCat table(

    Claims int,

    Category char(2)

    );

    insert into @ClaimCat

    select 12345, 'P1' union all

    select 42342, 'P2' union all

    select 4234234, 'P3'

    ;

    select * from @ClaimCat;

    select

    Claims,

    case when Category = 'P1' then 'X' else '' end as P1,

    case when Category = 'P2' then 'X' else '' end as P2,

    case when Category = 'P3' then 'X' else '' end as P3

    from

    @ClaimCat

    ;

  • Thank you very much lynn

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply