how can i solve this query [message #268971] |
Thu, 20 September 2007 04:57 |
LAZYGIRL
Messages: 34 Registered: May 2006
|
Member |
|
|
i have a query to calculate the diff between two date by month intrval
i want somthing like this
decode (round ((sysdate-t.rqsmaxdlvdat)/30)>3 ,'thee_month','more')
|
|
|
|
Re: how can i solve this query [message #269006 is a reply to message #268972] |
Thu, 20 September 2007 07:42 |
LAZYGIRL
Messages: 34 Registered: May 2006
|
Member |
|
|
Michel Cadot wrote on Thu, 20 September 2007 05:01 | months_between is a standard function.
Regards
Michel
|
thanks dear bro but my main question is about how can i decode the result if it is >3 it well display 'three month'
decode well work in case of equal but i want equal and greater
do you have any idea how to do it
|
|
|
Re: how can i solve this query [message #269012 is a reply to message #268971] |
Thu, 20 September 2007 07:51 |
smartin
Messages: 1803 Registered: March 2005 Location: Jacksonville, Florida
|
Senior Member |
|
|
In fairness, your original question was not all that clear. But will this work?
MYDBA@orcl > select case when 5 > 3 then 'Yep' else 'Nope' end from dual;
CASE
----
Yep
1 row selected.
MYDBA@orcl > select case when 5 > 8 then 'Yep' else 'Nope' end from dual;
CASE
----
Nope
1 row selected.
[Updated on: Thu, 20 September 2007 07:52] Report message to a moderator
|
|
|
Re: how can i solve this query [message #269013 is a reply to message #269006] |
Thu, 20 September 2007 07:52 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
1) The easy way: Use the CASE statmentCASE WHEN a<b then 'Less than' WHEN a=b then 'Equal' ELSE 'Greater Than' END
2) The difficult way: (for people still using 8i)DECODE(sign(a-b),-1,'Less than',0,'Equal',1,'Greater Than')
|
|
|
|