Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 2nd, 2008, 12:40 AM
Authorized User
 
Join Date: Apr 2007
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





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.