Home » SQL & PL/SQL » SQL & PL/SQL » how can i solve this query
how can i solve this query [message #268971] Thu, 20 September 2007 04:57 Go to next message
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 #268972 is a reply to message #268971] Thu, 20 September 2007 05:01 Go to previous messageGo to next message
Michel Cadot
Messages: 68719
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
months_between is a standard function.

Regards
Michel
Re: how can i solve this query [message #269006 is a reply to message #268972] Thu, 20 September 2007 07:42 Go to previous messageGo to next message
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 Go to previous messageGo to next message
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 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
1) The easy way: Use the CASE statment
CASE 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')

Re: how can i solve this query [message #269126 is a reply to message #269013] Thu, 20 September 2007 15:09 Go to previous message
LAZYGIRL
Messages: 34
Registered: May 2006
Member
thanx you all

you give me a good help


i forget about case statment

thanks very much
Previous Topic: Is there any Data dictionary table to track a package variable?
Next Topic: i need to email invoices to customers
Goto Forum:
  


Current Time: Sun Dec 08 19:07:38 CST 2024