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: sql or pl sql to do this?

Re: sql or pl sql to do this?

From: Pablo Sanchez <pablo_at_dev.null>
Date: Mon, 13 May 2002 06:06:20 -0600
Message-ID: <3cdfaaa8$1_13@news.teranews.com>

"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'

FROM objects

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 contracts
Received on Mon May 13 2002 - 07:06:20 CDT

Original text of this message

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