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 -> Re: return column in select based on another column value

Re: return column in select based on another column value

From: Ed Prochak <edprochak_at_gmail.com>
Date: Mon, 3 Dec 2007 11:14:45 -0800 (PST)
Message-ID: <624ec212-d021-4c24-877f-e8eee481e708@y5g2000hsf.googlegroups.com>


On Dec 3, 1:58 pm, kishjeff <kishjj..._at_charter.net> wrote:
> Hi.
> This is sort of like asking how to do a comma operator in sql on
> Oracle.
> I'm not sure how to approach asking the question, or even search for
> it except
> for posting the question here.
>
> If I have this table (2 cols, 1st row is col name):
>
> col1 col2
> type1 def5
> type2 abc4
> type1 null
> type3 null
>
> I'd like to have a select statement return this:
>
> colz coly
> null def5 because it is type1 return col2 as 2nd col
> abc4 null because it is type2 return col2 as 1st col
> null null
> null null
>
> in other words I'd like to have a certain column in the result set
> return:
> col2 in coly or col2 in colz based on value of col1
>
> What is the best way to do this with an sql query, or is it even
> possible?
> I'm targeting Oracle 9i onwards
> thanks for even a hint.. I can look up the details.

look up the CASE clause
  Ed Received on Mon Dec 03 2007 - 13:14:45 CST

Original text of this message

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