Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Analyzing This Query?

Analyzing This Query?

From: <pankaj_wolfhunter_at_yahoo.co.in>
Date: 12 Feb 2006 22:40:08 -0800
Message-ID: <1139812808.511696.85250@g47g2000cwa.googlegroups.com>


Greetings,

I have a query

SELECT       DECODE(SODC.CONTRASEQNUMBER, 1, SODC.CONTRAQUANTITY,0) CQTY1,       DECODE(SODC.CONTRASEQNUMBER, 2, SODC.CONTRAQUANTITY,0) CQTY2,       DECODE(SODC.CONTRASEQNUMBER, 3, SODC.CONTRAQUANTITY,0) CQTY3,       DECODE(SODC.CONTRASEQNUMBER, 4, SODC.CONTRAQUANTITY,0) CQTY4,       DECODE(SODC.CONTRASEQNUMBER, 5, SODC.CONTRAQUANTITY,0) CQTY5,       DECODE(SODC.CONTRASEQNUMBER, 1, SODC.CONTRANAME,0) CONTRA1,       DECODE(SODC.CONTRASEQNUMBER, 2, SODC.CONTRANAME,0) CONTRA2,       DECODE(SODC.CONTRASEQNUMBER, 3, SODC.CONTRANAME,0) CONTRA3,       DECODE(SODC.CONTRASEQNUMBER, 4, SODC.CONTRANAME,0) CONTRA4,       DECODE(SODC.CONTRASEQNUMBER, 5, SODC.CONTRANAME,0) CONTRA5, FROM
        SEMCOMPANIES SODC As we can see that the CONTRASEQNUMBER is checked first from the value 1 to 5 to give the output as CQTY1, CQTY2 etc and then again is checked from 1 through 5 to give the result as CONTRA1, CONTRA2, etc
i.e according to the flow, CONTRASEQNUMBER is checked twice for the same values

I just wanted to know is there any way these two results can be obtained
where the CONTRASEQNUMBER is checked only once from 1 to 5 or is there any other recommended approach to follow?

We are using Oracle 10g.

Any help would be greatly appreciated

TIA Received on Mon Feb 13 2006 - 00:40:08 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US