Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Help - Pivot table Expand / Collapse
Author
Message
Posted Thursday, August 7, 2014 7:57 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, September 4, 2014 12:04 AM
Points: 63, Visits: 55
Hi

I have a table like below.
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

I want to table output like below

ID 1033COUNT 1033COUNT 1034COUNT 1034COUNT
41772 1 7 6 1
10000 1 7 6 1
10000 1 7 6 1

Please help. Thanks
Post #1600633
Posted Thursday, August 7, 2014 8:12 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:23 AM
Points: 5,074, Visits: 11,852
m.mukesh.mca2009 (8/7/2014)
Hi

I have a table like below.
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

I want to table output like below

ID 1033COUNT 1033COUNT 1034COUNT 1034COUNT
41772 1 7 6 1
10000 1 7 6 1
10000 1 7 6 1

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.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1600653
Posted Thursday, August 7, 2014 8:29 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Sunday, September 7, 2014 11:27 PM
Points: 7,164, Visits: 13,257
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
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #1600665
Posted Thursday, August 7, 2014 9:53 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Saturday, September 13, 2014 1:04 PM
Points: 4,356, Visits: 6,186
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 at GMail
Post #1600726
Posted Thursday, August 7, 2014 10:07 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, September 4, 2014 12:04 AM
Points: 63, Visits: 55
Hi, eID have only unique values but ID may have duplicate values
Post #1601013
Posted Friday, August 8, 2014 12:07 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:23 AM
Points: 5,074, Visits: 11,852
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?



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1601032
Posted Friday, August 8, 2014 1:30 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Sunday, September 7, 2014 11:27 PM
Points: 7,164, Visits: 13,257
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
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #1601058
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse