Need to select data from 2 rows into one row depending on types

  • Hi. I have a table with 5 columns, NAME, answertype(1=Yes, 2=No),amount of answers,YES, NO..

    NAME answtype amount YES NO

    KVANTUM1 3 Yes-

    KVANTUM2 5 -No

    MAXI 1 8 Yes -

    MAXI 2 3 -No

    SUPERMARKET1 1 Yes-

    SUPERMARKET2 11 -NEJ

    I want to display just one NAME on each row and the amount of YES and NO on that row.Like this..

    NAME answtype amount YES NO

    KVANTUM1 3 35

    MAXI 1 8 8 3

    SUPERMARKET1 1 111

    ANY idea how I should do this ?? I have tried likes this, but it will just be like the table on top..

    select NAME,answtype,amount, YES = case when answtype = 1 then sum(amount) else 0 END,

    NO = case when answtype = 2 then sum(amount)else 0 END

    from TABLE group by NAME,answtype,amount, YES, NO

    ENDS up like that..

    KVANTUM1110

    KVANTUM2505

    MAXI 1110

    MAXI 2303

    SUPERMARKET1110

    SUPERMARKET211011

    I need this to work for a bettar report.. I hope I get any answer..

    Regards / Uffe

  • Please have a look at the cross tab article referenced in my signature.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

Viewing 2 posts - 1 through 2 (of 2 total)

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