how to display single column in result

  • select

    case when Profesenalism=1 then count(Profesenalism) end as 'Profesenalismpoor',

    case when profesenalism=2 then count (profesenalism) end 'profesenalismavg',

    case when Communication=1 then count(Communication) else 0 end 'Communicationpoor',

    case when Communication=2 then count (Communication) else 0 end 'Communicationavg',

    case when Customerservice=1 then count(Customerservice) else 0 end 'Communicationpoor',

    case when Customerservice=2 then count (Customerservice) else 0 end 'Communicationavg'

    from Rating where profileid=101

    group by Profesenalism,Communication,Customerservice

    please check attachment for query...

    out put displaying llike attched output jped..

    i need result in one single row.............

  • Not really clear on your question....???

    can you please provide script that will create and insert data that represents the problem you have..(see link in my sig if not clear)

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • dastagiri16 (10/1/2011)


    select

    case when Profesenalism=1 then count(Profesenalism) end as 'Profesenalismpoor',

    case when profesenalism=2 then count (profesenalism) end 'profesenalismavg',

    case when Communication=1 then count(Communication) else 0 end 'Communicationpoor',

    case when Communication=2 then count (Communication) else 0 end 'Communicationavg',

    case when Customerservice=1 then count(Customerservice) else 0 end 'Communicationpoor',

    case when Customerservice=2 then count (Customerservice) else 0 end 'Communicationavg'

    from Rating where profileid=101

    group by Profesenalism,Communication,Customerservice

    please check attachment for query...

    out put displaying llike attched output jped..

    i need result in one single row.............

    We need some data to show you how to do this. However, don't assume that you know how to post the data. Please read the article at the first link in my signatue line below for how to post data to get the right answer more quickly.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • hi,

    my table data is ...

    id Profesenalism Communication Customerservice profileid

    1001 1 2 1 101

    2001 2 1 1 101

    the above table 1 and 2 is ratings.. if 1 that is poor and 2 that is avg..i need count of profesenalismpoor ? and count of profesenalismavg ?..like Communicationpoor,Communicationavg,Customerservicepoor,Customerserviceavg.........

    i need out put like dis..

    Profesenalismpoor profesenalismavg Communicationpoor Communicationavg Customerservicepoor cusavg

    1 1 1 1 2 0

    I wrote my query like dis..

    select

    case when Profesenalism=1 then count(Profesenalism) end as 'Profesenalismpoor',

    case when profesenalism=2 then count (profesenalism) end 'profesenalismavg',

    case when Communication=1 then count(Communication) else 0 end 'Communicationpoor',

    case when Communication=2 then count (Communication) else 0 end 'Communicationavg',

    case when Customerservice=1 then count(Customerservice) else 0 end 'Customerservicepoor',

    case when Customerservice=2 then count (Customerservice) else 0 end 'Customerserviceavg'

    from Rating where profileid=101

    group by Profesenalism,Communication,Customerservice

    it is displaying another extra column.......please advice

  • May be this?

    declare @tab Table

    ( id int,

    professionalism int,

    communication int,

    customerservice int,

    profileid int

    )

    insert @tab( id , professionalism , Communication ,Customerservice ,profileid)

    select 1001 ,1 ,2 ,1 ,101

    union all select 2001 ,2 ,1 ,1 ,101

    Select

    ProfessionalismPoor = sum ( case when professionalism = 1 then 1 else 0 end )

    , ProfessionalismAvg = sum ( case when professionalism = 2 then 1 else 0 end)

    , CommunicationPoor = sum ( case when Communication = 1 then 1 else 0 end )

    , CommunicationAvg = sum ( case when Communication = 2 then 1 else 0 end)

    , CustomerServicePoor = sum ( case when CustomerService = 1 then 1 else 0 end )

    , ProfessionalismAvg = sum ( case when CustomerService = 2 then 1 else 0 end)

    from @tab

  • hi,

    Thanks ..alot.....for u r reply...........Its working ........fine

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

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