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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query - SQL or PL/SQL? 1

Status
Not open for further replies.

Kahlor

Programmer
Jun 21, 2002
13
0
0
Hi,
I have a simple query that pulls information from a table:
Code:
Select Field1, Field2
From MyTable
Where Field2 < (sysdate - 30);
(Field2 is a date field. This query lists everything that is over 30 days old.) What I want to add next to this query is:
If Field2 is under 30 days old then return the words &quot;In Process&quot; (instead of the actual date in the table).
So, on the report you would see something like:
Code:
FIELD1   FIELD2
------   ----------
1234     06-JUN-02
2345     12-JUL-02
3456     In Process
4567     24-MAY-02
5678     In Process
How would I do this?

Any and all help is appreciated! Thank you!
 
A query like the following should work.

select field1,
decode(sign(sysdate-field2-30),
1,to_char(field2),
0,to_char(field2),
-1,'In Process') from MyTable;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top