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

Home -> Community -> Usenet -> c.d.o.tools -> CASE construct in SELECT statement

CASE construct in SELECT statement

From: Anson Parker <ans_at__nospam_x64.net>
Date: Thu, 18 Jan 2001 05:46:40 GMT
Message-ID: <4rv96.67980$xW4.528886@news-server.bigpond.net.au>

Ok, I'm pretty green with Oracle - I'm a MySQL user most of the time. I'm currently trying to provide Oracle support in a web application I've built currently for MySQL. So far I've been able to survive on the Oracle Technet docs - that is until now...

(BTW: I'm running Oracle 8.1.6 on Linux)

In MySQL I have a rather large select statement making use of a case construct. It looks something like this (to use the infamous employee e.g.):

SELECT firstname, lastname, CASE WHEN salary>80000 THEN 'big time'

    WHEN salary < 20000 THEN 'small fry' ELSE 'middle management' END     FROM employee_table;

You should be able to see the basic principle anyway. I'd like to do this same
logic in a PL/SQL statement to my Oracle database (obviously the above example is a custom MySQL extension).

Can I do this inline (within a SELECT statement)? Or do I have to venture into
the deep unknown of procedures? It's not a common query and it's the only time I have to stray beyond basic SQL calls so I'd rather stick to the inline
method, albeit a little offensive to the eye, if I can.

Anson. Received on Wed Jan 17 2001 - 23:46:40 CST

Original text of this message

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