Help - Pivot table

  • Hi

    I have a table like below.

    ID eIDinCountoutCount

    417720NULL NULL

    1000010331 7

    1000010346 1

    100001035NULL 1

    1000010361 NULL

    1000010362 NULL

    1000010361 1

    I want to table output like below

    ID1033COUNT1033COUNT1034COUNT1034COUNT

    417721761

    100001761

    100001761

    Please help. Thanks

  • m.mukesh.mca2009 (8/7/2014)


    Hi

    I have a table like below.

    ID eIDinCountoutCount

    417720NULL NULL

    1000010331 7

    1000010346 1

    100001035NULL 1

    1000010361 NULL

    1000010362 NULL

    1000010361 1

    I want to table output like below

    ID1033COUNT1033COUNT1034COUNT1034COUNT

    417721761

    100001761

    100001761

    Please help. Thanks

    You have duplicate rows and duplicate columns in your sample output. Can you explain why? Or correct it to match what you really want.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Also, please verify that your expected output is based on your sample data. I'd expect the current version doesn't.



    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]

  • While you are figuring out what you really want (and scripting sample tables/data for us to help you better), search the web for sql server CASE pivot and see if you can do it yourself

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

  • Hi, eID have only unique values but ID may have duplicate values

  • m.mukesh.mca2009 (8/7/2014)


    Hi, eID have only unique values but ID may have duplicate values

    By being lazy and not providing what people are asking for, you are making this thread more painful than it needs to be.

    If you will not take the time to provide accurate sample data and desired output which matches the sample data, why should the unpaid volunteers here take the time to help you out?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • m.mukesh.mca2009 (8/7/2014)


    Hi, eID have only unique values but ID may have duplicate values

    That doesn't match the sample data you provided.

    ID eID inCount outCount

    41772 0 NULL NULL

    10000 1033 1 7

    10000 1034 6 1

    10000 1035 NULL 1

    10000 1036 1 NULL

    10000 1036 2 NULL

    10000 1036 1 1

    Seems like you're not really interested to get the issue resolved. I'm out.



    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 7 posts - 1 through 6 (of 6 total)

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