Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditionally Selecting Fields

Status
Not open for further replies.

AmunRa

Technical User
Aug 14, 2003
9
0
0
GB
I have a table with fields called F3,F4,F5,F6,F7,F8,F9,F10.

I want to conditionalyy select these fields i.e.

If todays date is between 1/1/2003 and 30/4/2003 then select F3,F4,F5
Else if it is betwwen 1/5/2003 and 30/9/2003 then
select F6,F7,F8
Else select F9,F10.

Can anybody help with the syntax to do this please.
 
Code:
select case when current_date 
between date '2003-01-01' and date '2003-04-30' then
   (f3,f4,f5)
when hen current_date 
between date '2003-05-01' and date '2003-09-30' then
   (f6,f7,f8)
else (f9,f10,cast(null as <same datatype as f5 and f8>))
from t

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top