。我有以下代码
SELECT BRCODE,PRCODE,SHORTNAME,SUM(NVL(CUMSALE,0)-NVL(CUMCRD,0)) NETSALE,SUM(CUMTAR) TRGT,ROUND(SUM(NVL(CUMSALE,0)-NVL(CUMCRD,0))/SUM(CUMTAR)*100,2) ACH
case
when regexp_like(:lprdate, 'OCT' ) = 'OCT' then
select statement for OCT
when regexp_like(:lprdate, 'NOV' ) = 'NOV' then
select statement for NOV
when regexp_like(:lprdate, 'JAN' ) = 'DEC' then
select statement for DEC
ELSE
SELECT BRCODE,PRCODE,SHORTNAME,SUM(NVL(CUMSALE,0)-NVL(CUMCRD,0)) NETSALE,SUM(CUMTAR) TRGT,ROUND(SUM(NVL(CUMSALE,0)-NVL(CUMCRD,0))/SUM(CUMTAR)*100,2) ACH
FROM ANALYSIS1 WHERE LASTRPTDT1 = :lprdate1 GROUP BY BRCODE,PRCODE,SHORTNAME order by BRCODE,PRCODE
END
此处:lprdate和:lprdate1是生成报告时触发的用户输入。 用户可以输入10月,11月,12月:lprdate和Jan:lprdate1。 本案例陈述是否有助于根据案例陈述中给出的条件提供结果?
例如,如果我给:lprdate =' 31-OCT-17' ,这会在第一种情况下进行吗? 请帮忙。 不,由于软件的一些技术问题,我没有尝试过代码。如果我知道这个解决方案是否有效,我很乐意快速执行
答案 0 :(得分:0)
您可以尝试这样的事情:
select monthname, somenumber, sometext
from
( select 'OCT' as monthname, 123 as somenumber, 'Demo for October' as sometext from dual
union all
select 'NOV' as monthname, 456 as somenumber, 'Demo for November' as sometext from dual
union all
select 'DEC' as monthname, 789 as somenumber, 'Demo for December' as sometext from dual
)
where monthname = :param;