Home » SQL & PL/SQL » SQL & PL/SQL » oracle sql short
oracle sql short [message #263938] |
Fri, 31 August 2007 05:33 |
harini.ss
Messages: 3 Registered: August 2007 Location: chennai
|
Junior Member |
|
|
SELECT DISTINCT DECODE(SUBSTR(DOCDATE,4,3),'JAN', 'JANUARY',DECODE(SUBSTR(DOCDATE,4,3),'FEB','FEBRUARY',DECODE(SUBSTR(DOCDATE,4,3),'MAR', 'MARCH',DECODE(SUBSTR(DOCDATE,4,3),'APR','APRIL',DECODE(SUBSTR(DOCDATE,4,3),
'MAY', 'MAY',DECODE(SUBSTR(DOCDATE,4,3),'JUN','JUN',DECODE(SUBSTR(DOCDATE,4,3),'JULY', 'JULY',DECODE(SUBSTR(DOCDATE,4,3),'AUG','AUG','DEC')))))))) FROM EXINVBASIC
WHERE SUBSTR(DOCDATE,4,3) IS NOT NULL
this is my sql
How can i short this sql
Harini
|
|
|
|
|
Re: oracle sql short [message #263945 is a reply to message #263938] |
Fri, 31 August 2007 05:51 |
|
vamsi kasina
Messages: 2112 Registered: October 2003 Location: Cincinnati, OH
|
Senior Member |
|
|
Quote: | DECODE(SUBSTR(DOCDATE,4,3),'JUN','JUN'
|
Quote: | DECODE(SUBSTR(DOCDATE,4,3),'AUG','AUG','DEC'
| Is it a typo?
By
Vamsi
|
|
|
|
Re: oracle sql short [message #263971 is a reply to message #263938] |
Fri, 31 August 2007 07:01 |
lenin_babu55
Messages: 12 Registered: August 2007
|
Junior Member |
|
|
hi
it is not necessary to write decode function that many times
refer the following code ..........
SELECT product_id,
DECODE (warehouse_id, 1, 'Southlake',
2, 'San Francisco',
3, 'New Jersey',
4, 'Seattle',
'Non-domestic')
quantity_on_hand FROM inventories;
|
|
|
|
Re: oracle sql short [message #264085 is a reply to message #263938] |
Fri, 31 August 2007 13:13 |
|
cmerry
Messages: 109 Registered: November 2005 Location: Idaho
|
Senior Member |
|
|
First of all, what datatype is DOCDATE? I'm assuming since you are using SUBSTR, it is character of some type and not DATE.
Second, this condition will never be true
Quote: | SUBSTR(DOCDATE,4,3),'JULY'
|
And third, do you really want the mixed results (i.e. some months spelled out, some months abbreviated, and a default of 'DEC' for all months after 'AUG'), or were you being lazy? I'm okay with that, but mentioning that in your post would be nice.
|
|
|
Goto Forum:
Current Time: Sat Dec 07 00:44:55 CST 2024
|