Home » SQL & PL/SQL » SQL & PL/SQL » Error in decode function?
Error in decode function? [message #354105] Thu, 16 October 2008 07:53 Go to next message
tondapi
Messages: 99
Registered: August 2007
Location: usa
Member
Hi,



If fin_no is either 1001xxxx or 1211xxx i want to display 'need'.i used below decode query.But it showing error.
Can any one help me.I use case but we want to display with decode function.


SUM(DECODE(accounts.FIN_NO,'1001%'or '1211%','need')) AS sales
Re: Error in decode function? [message #354111 is a reply to message #354105] Thu, 16 October 2008 08:11 Go to previous messageGo to next message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
You're a funny guy. You say you know how to do it with CASE but you want to use DECODE? That's pretty funny, since you are not even using the correct syntax for DECODE. If you know how to do it one way and you don't know how to use it another way, why would one choose to use the way they do not know how to use?

Look in the documentation for SUBSTR, LENGTH and DECODE function.

http://tahiti.oracle.com

[Updated on: Thu, 16 October 2008 08:13]

Report message to a moderator

Re: Error in decode function? [message #354112 is a reply to message #354105] Thu, 16 October 2008 08:11 Go to previous messageGo to next message
joicejohn
Messages: 327
Registered: March 2008
Location: India
Senior Member
@tondapi,

Can you post what error you are getting?

Besides do you think SUM Function will work on a string?

SQL> select SUM('need') from Dual;
select SUM('need') from Dual
           *
ERROR at line 1:
ORA-01722: invalid number


Regards,
Jo

[Updated on: Thu, 16 October 2008 08:13]

Report message to a moderator

Re: Error in decode function? [message #354125 is a reply to message #354111] Thu, 16 October 2008 08:41 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
"funny" is not the word I'd use.

Regards
Michel
Re: Error in decode function? [message #354157 is a reply to message #354125] Thu, 16 October 2008 13:02 Go to previous message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
I was being kind.

You would think that after a year on the forum, someone would know basic SQL skills, in additional to knowing that you start with the documentation. And I mentioned this before, hobby of user is "searching." I think that needs to be changed, or it might be a definition of "searching" that I am not aware of.
Previous Topic: How can one make a Distinct Multiplication Table ?
Next Topic: How To identify the tables from a dblinks seeing at a procedure
Goto Forum:
  


Current Time: Sat Dec 03 07:47:19 CST 2016

Total time taken to generate the page: 0.16413 seconds