Home » Other » Training & Certification » decode problem
decode problem [message #265853] Fri, 07 September 2007 11:36 Go to next message
ashish2345
Messages: 50
Registered: September 2007
Member
I use oracle 9i. i had one question on decode.
my table member has columns age and name.
i want to decode my info as follows

age<18 minor
age =18 adult
age>18 and <60 mature
age>60 old

how can i do it in one statement...
thanks a lot in advance
Re: decode problem [message #265859 is a reply to message #265853] Fri, 07 September 2007 12:01 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Say what you already tried, you don't do your homework, we just help you.

Regards
Michel
Re: decode problem [message #265867 is a reply to message #265853] Fri, 07 September 2007 12:54 Go to previous messageGo to next message
muzahid
Messages: 281
Registered: September 2004
Location: Dhaka, Bangladesh
Senior Member
Use sign function in decode function.
Re: decode problem [message #265871 is a reply to message #265853] Fri, 07 September 2007 13:04 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Use "case" for complex conditions, let decode for old people.

Regards
Michel
Re: decode problem [message #265885 is a reply to message #265871] Fri, 07 September 2007 13:51 Go to previous messageGo to next message
joy_division
Messages: 4643
Registered: February 2005
Location: East Coast USA
Senior Member
Michel Cadot wrote on Fri, 07 September 2007 14:04
Use "case" for complex conditions, let decode for old people.

Regards
Michel



I am pretty old and I do use decode, so hmmmm....what are you saying Wink
Re: decode problem [message #265891 is a reply to message #265885] Fri, 07 September 2007 14:05 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
what are you saying

I love decode. Cool

Regards
Michel
Re: decode problem [message #266006 is a reply to message #265853] Sat, 08 September 2007 22:06 Go to previous messageGo to next message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

Decode needs less writing. I love it. Cool
Re: decode problem [message #266036 is a reply to message #266006] Sun, 09 September 2007 04:30 Go to previous message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
In simple cases, DECODE and CASE don't differ much; I prefer DECODE.

However, when there are nested DECODEs involved, it may be a real pain to write (and, especially, read an understand) it correctly, while CASE offers better comprehension of the same query.

Previous Topic: how to allow full access/control to a Oracle user?
Next Topic: Which Oracle Apps course/module I should opt for?
Goto Forum:
  


Current Time: Thu Dec 08 16:19:50 CST 2016

Total time taken to generate the page: 0.07586 seconds