Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 PIVOT TABLE HELP
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

julius.delorino
Starting Member

Philippines
29 Posts

Posted - 09/27/2012 :  03:14:24  Show Profile  Reply with Quote
-------------
Source Table
-------------
TerminalID TerminalDesc msgtype ResponseCode ErrorDesc ErrorGroup TotalCount
8880001 NATCCO CF 210 00NH BATCH IN PROG Customer-Related Rejects 6
8880001 NATCCO CF 210 00NG NULL Customer-Related Rejects 1
8880001 NATCCO CF 210 92 DESTINATION NOT FOUND Customer-Related Rejects 3
8880001 NATCCO CF 210 91 ISSUERISDOWN Customer-Related Rejects 4
8880001 NATCCO CF 210 75 MAXPINTRY Customer-Related Rejects 24
8880001 NATCCO CF 210 68 TIMEOUT Customer-Related Rejects 4
8880001 NATCCO CF 210 61 EXCEEDEDDAILYAMTLIMIT Customer-Related Rejects 10
8880001 NATCCO CF 210 55 INVALID PIN Customer-Related Rejects 24
8880001 NATCCO CF 210 52 INVALID ACCOUNT Customer-Related Rejects 12
8880001 NATCCO CF 210 51 INSUFFICIENT FUNDS Customer-Related Rejects 50
8880001 NATCCO CF 210 38 NULL Customer-Related Rejects 14
8880001 NATCCO CF 210 30 INVALIDMSGFORMAT Customer-Related Rejects 1
8880001 NATCCO CF 210 25 INVALIDCURRENTACCT Customer-Related Rejects 10
8880001 NATCCO CF 210 19 SYSTEMERROR Customer-Related Rejects 5
8880001 NATCCO CF 210 14 INVALID CARD NUMBER Customer-Related Rejects 2
8880001 NATCCO CF 210 12 INVALIDTRANCODE Customer-Related Rejects 2
8880001 NATCCO CF 210 5 UNABLETOPROCESS Customer-Related Rejects 10
8880001 NATCCO CF 210 0 APPROVED Customer-Related Rejects 1000

---------------
Desired Output
---------------
ResponseCode ErrorDesc ErrorGroup 8880001
00NH BATCH IN PROG Customer-Related Rejects 6
00NG NULL Customer-Related Rejects 1
92 DESTINATION NOT FOUND Customer-Related Rejects 3
91 ISSUERISDOWN Customer-Related Rejects 4
75 MAXPINTRY Customer-Related Rejects 24
68 TIMEOUT Customer-Related Rejects 4
61 EXCEEDEDDAILYAMTLIMIT Customer-Related Rejects 10
55 INVALID PIN Customer-Related Rejects 24
52 INVALID ACCOUNT Customer-Related Rejects 12
51 INSUFFICIENT FUNDS Customer-Related Rejects 50
38 NULL Customer-Related Rejects 14
30 INVALIDMSGFORMAT Customer-Related Rejects 1
25 INVALIDCURRENTACCT Customer-Related Rejects 10
19 SYSTEMERROR Customer-Related Rejects 5
14 INVALID CARD NUMBER Customer-Related Rejects 2
12 INVALIDTRANCODE Customer-Related Rejects 2
5 UNABLETOPROCESS Customer-Related Rejects 10
0 APPROVED Customer-Related Rejects 1000




please help me how to attain that kind of output table,thank you and more power.

sql-programmers
Posting Yak Master

USA
190 Posts

Posted - 09/27/2012 :  05:38:11  Show Profile  Visit sql-programmers's Homepage  Reply with Quote
You can get desired output from this query then Why you are going to PIVOT?

SELECT ResponseCode, ErrorDesc, ErrorGroup, TotalCount FROM <TABLE NAME>


SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 09/27/2012 :  10:27:38  Show Profile  Reply with Quote
where did you get value 8880001 from?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000