当我尝试运行类似于下面的代码时,我得到了ORA-00907:错过了正确的paranthesis错误。似乎我已正确关闭所有的paranthesis。
任何人都可以帮我解决这个问题。感谢
with cte_tab1 as (
select
tab1.*,
case
when count(distinct Tab1.col_type) over (partition by Tab1.co_new) >1
then T_CDR.sales - nvl(T_CDR.profit,0) - nvl(T_CDR.proinf,0)
else 0
end as rsec_col
from tab1
),
CV as (
select
case
when tab1.pro_cat in ('RP', 'DE', 'OT', 'CD')
then 'TC'
when tab1.mew = 'TD' and tab1.d_type <> 'BS'
then 'PREM'
else 'TC'
end as bsspl_new,
sum(nvl(tab1.sales,0)) as gross_sal,
sum(tab1.rsec_col) as seccol
from cte_tab1 as tab1
group by
case
when tab1.pro_cat in ('RP', 'DE', 'OT', 'CD')
then 'TC'
when tab1.mew = 'TD' and tab1.d_type <> 'BS'
then 'PREM'
else 'TC'
end
)
select cv.bsspl_new,
cv.gross_sal as gsl,
cv.seccol as ssl
from cv
答案 0 :(得分:0)
Oracle中的表别名不支持从cte_tab1作为tab1
AS
关键字。删除它,你不会得到错误。
将其修改为:
from cte_tab1 tab1