Why cannot substr be used in case when in Oracle 10 Gb ????

Source: Internet
Author: User

 

Select GRP, site, item, sum (plan_qty), sum (diff_qty)

From (

Select/* case

When substr (productid, 1, 1) = 'l' then

'Sesl'

When substr (productid, 1, 1) = 'M' then

'Lcm'

Else

Substr (productid, 1, 1)

End "GRP ",*/

Decode (substr (productid, 1, 1), 'l', 'sesl ', 'M', 'lcm', substr (productid, 1, 1) "GRP ",

Case

When currentsite = 'modproc' then

'S1mod'

When currentsite = 'modproc2 'then

'S2mod'

Else

Currentsite

End "Site", floorid item, plan_qty, diff_qty

From (

Select 'ltm0000e4-L02-LLC5 'As productid, 'modproc' as currentsite, '1f' floorid, 1 plan_qty, 2 diff_qty from dual

Union all

Select 'mtn0000e4-L02-LLC5 'As productid, 'modproc2' As currentsite, '2f 'floorid, 3 plan_qty, 4 diff_qty from dual

)

) Group by GRP, site, item

;

------------------ When case when is used, an error is reported .....

 

Select GRP, site, item, sum (plan_qty), sum (diff_qty)

From (

Select case

When substr (productid, 1, 1) = 'l' then

'Sesl'

When substr (productid, 1, 1) = 'M' then

'Lcm'

Else

Substr (productid, 1, 1)

End "GRP ",

--- Decode (substr (productid, 1, 1), 'l', 'sesl ', 'M', 'lcm', substr (productid, 1, 1 )) "GRP ",

Case

When currentsite = 'modproc' then

'S1mod'

When currentsite = 'modproc2 'then

'S2mod'

Else

Currentsite

End "Site", floorid item, plan_qty, diff_qty

From (

Select 'ltm0000e4-L02-LLC5 'As productid, 'modproc' as currentsite, '1f' floorid, 1 plan_qty, 2 diff_qty from dual

Union all

Select 'mtn0000e4-L02-LLC5 'As productid, 'modproc2' As currentsite, '2f 'floorid, 3 plan_qty, 4 diff_qty from dual

)

) Group by GRP, site, item

;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.