Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: sql or pl sql to do this?
"gil guerillot" <gil.guerillot_at_ratp.fr> wrote in message
news:abo296$1f70$1_at_gotix.reseau.ratp...
> i 'd like to know with sql if an object is installed between 2
dates
> (start_date and end_date) in a where clause
>
> table objects: code_object,date_in ,date_out
>
> i want a result like this
>
> object1 yes
> object2 yes
> object3 no
> object4 yes ....
Hi Gil,
With SQL, you can do the above several ways ... either using the CASE or DECODE functions - CASE is ANSI SQL and if you code it in PL/SQL, will only work with 9i unless you use dynamic SQL prior to that:
SELECT code_object, CASE WHEN install_date BETWEEN date_in AND date_out 'Yes'
ELSE 'No'
Note: You didn't provide the name of the column that contained the install_date so I made it up. <g>
See the Oracle docs for DECODE. :)
-- Pablo Sanchez, High-Performance Database Engineering mailto:pablo_at_hpdbe.com http://www.hpdbe.com Available for short-term and long-term contractsReceived on Mon May 13 2002 - 07:06:20 CDT