Home » SQL & PL/SQL » SQL & PL/SQL » Decode Function Help
Decode Function Help [message #333476] Fri, 11 July 2008 17:39 Go to next message
bhagwan_singh
Messages: 3
Registered: July 2008
Junior Member
Hi all,

I am trying to get a logical expression that has 3 possible outcomes.

The example is if the difference from Last Updated and Created date is less than 24 hours, then display as 24, if between 24 and 48 hours, display as 48, and if greater than 48, display as 48+.

I have figured out how to get less than 24 hours, to display 24, and greater than 24 to display 24+, but have not found a way to have 3 possible outputs using a single DECODE function.

Can anyone help me on this?

Thanks,

BS
Re: Decode Function Help [message #333477 is a reply to message #333476] Fri, 11 July 2008 17:58 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
not possible with a single decode. Nest one decode inside another to achieve your goals
Re: Decode Function Help [message #333478 is a reply to message #333477] Fri, 11 July 2008 17:59 Go to previous messageGo to next message
bhagwan_singh
Messages: 3
Registered: July 2008
Junior Member
Can you write that sql for me please?Iam a newbie here
Re: Decode Function Help [message #333504 is a reply to message #333476] Fri, 11 July 2008 23:53 Go to previous messageGo to next message
Michel Cadot
Messages: 64130
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why don't you want to use CASE instead?

Regards
Michel
Re: Decode Function Help [message #333535 is a reply to message #333478] Sat, 12 July 2008 04:51 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
bhagwan_singh wrote on Fri, 11 July 2008 23:59
Can you write that sql for me please?Iam a newbie here

Short answer? No.
I'm not here to do your work for you. I will happily help you if you put in some effort though. Give it a try, post what you tried and we can assist you further.
Re: Decode Function Help [message #333536 is a reply to message #333504] Sat, 12 July 2008 04:53 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
Michel Cadot wrote on Sat, 12 July 2008 05:53
Why don't you want to use CASE instead?

Regards
Michel


I would guess because he doesn't know about case. Wink
Re: Decode Function Help [message #333557 is a reply to message #333536] Sat, 12 July 2008 11:56 Go to previous messageGo to next message
bhagwan_singh
Messages: 3
Registered: July 2008
Junior Member
I will surely give a try using CASE statement.

But Can this be done using a decode function as well??
Re: Decode Function Help [message #333558 is a reply to message #333557] Sat, 12 July 2008 11:57 Go to previous message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
As I have already told you, yes.
Previous Topic: how to get the sample table?
Next Topic: Error in code - need help
Goto Forum:
  


Current Time: Wed Dec 07 08:29:35 CST 2016

Total time taken to generate the page: 0.07428 seconds