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

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Display format of results

Author  Topic 

sahu74
Posting Yak Master

100 Posts

Posted - 2003-05-08 : 12:06:33
I have the following results in a temporary table that I need to display in a different format.

ORG_DEPARTMENT  Fund    ACCOUNT_NBR10    Total Of FINAL_BGT  EXPB_REVB_IND
4OMINMED 6162 6162605256 -311235 EB
4OMINMED 6162 6162751199 311235 RB
4OMINMED 6780 6780785258 -1138431 EB
4OMINMED 6780 6780785258 1889673 RB
4OMINMED 6780 6780785442 -728274 EB


Desired Format:

ORG_DEPARTMENT Fund ACCOUNT_NBR10 Total Of FINAL_BGT EB RB
4OMINMED 6162 6162605256 -311235 -311235
4OMINMED 6162 6162751199 311235 311235
4OMINMED 6780 6780785258 751242 -1138431 1889673
4OMINMED 6780 6780785442 -728274 -728274


Any suggestions will be appreciated.

PKS.

chadmat
The Chadinator

1974 Posts

Posted - 2003-05-08 : 12:12:30
http://www.sqlteam.com/SearchResults.asp?SearchTerms=cross+tab

-Chad

http://www.clrsoft.com

Software built for the Common Language Runtime.
Go to Top of Page

shifis
Posting Yak Master

157 Posts

Posted - 2003-05-08 : 18:42:04
When you do the select that will feed your temporal table you can put a case instruction, for example:

CREATE TABLE #IC_DATE( ORG_DEPARTMENT (32), ...., EB INT, ER INT)
INSERT INTO #IC_DATE
SELECT ORG_DEPARTMENT , ....,
"EB"= CASE EXPB_REVB_IND
WHEN 'EB' THEN Total
ELSE 0 END,
"ER"= CASE EXPB_REVB_IND
WHEN 'ER' THEN Total
ELSE 0 END

FROM ICTRANS

If you don't want to show a cero in the EB or ER then you can convert the EXPB_REVB_IND to character.


Go to Top of Page
   

- Advertisement -