Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 2nd, 2008, 12:40 AM
Authorized User
 
Join Date: Apr 2007
Location: Silvassa, Dadra & Nagar Haveli, India.
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Decode function to display result in same row

How a decode function / statement in SQL can be written to display the result of the parameters used in decode statement in same row.

 Given the table as follows:
ITED_TED_CODE ITED_NET_LC_AMT
AED 0
BED 42063
EDU CESS 841
SHECESS 421
BED CT3 6825
EDU CESS CT3 137
SHECESS CT3 68

The decode statements are as follows.
NVL(DECODE(ITED_TED_CODE,'AED',ITED_NET_LC_AMT),0) AED,
NVL(DECODE(ITED_TED_CODE,'BED',ITED_NET_LC_AMT),0) BED,
NVL(DECODE(ITED_TED_CODE,'EDU CESS',ITED_NET_LC_AMT),0)EDU,
NVL(DECODE(ITED_TED_CODE,'SHECESS',ITED_NET_LC_AMT ),0) SHE,
NVL(DECODE(ITED_TED_CODE,'BED CT3',ITED_NET_LC_AMT),0) BEDCT3,
NVL(DECODE(ITED_TED_CODE,'EDU CESS CT3',ITED_NET_LC_AMT),0) EDUCT3,
NVL(DECODE(ITED_TED_CODE,'SHECESS CT3',ITED_NET_LC_AMT),0) SHE_CT3,


When executed for the above data gives the output as follows :
AED BED EDU_CESS SHECESS BED_CT3 EDU_CESS_CT3
0
    42063
         841
               421
                       1400
                               196




Whereas i want the output in first row in each column, as follows

 AED BED EDU_CESS SHECESS BED_CT3 EDU_CESS_CT3
0 42063 841 421 1400 196






Yogesh
__________________
Yogesh
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ToWords() function not displaying Result kavadoota Crystal Reports 0 November 28th, 2006 02:30 AM
How to display the result in sqlpus editor lily611 Oracle 3 November 22nd, 2006 03:26 PM
how to display the result elania PHP Databases 3 February 21st, 2005 03:07 PM
display the result of query in textbox. Abhinav_jain_mca ADO.NET 4 August 3rd, 2004 03:34 AM
getting a specific row from a MySQL result set Tachyon Beginning PHP 3 July 12th, 2004 11:55 AM



All times are GMT -4. The time now is 01:09 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.