我必须从表中的所有行中选择值,如下所示:
select distinct SCHM_CODE,
sum(DEP_AMT) as AMOUNT
from DLY_DEP_VIEW
where Schm_code in (select SCHM_CODE
from DLY_DEP_VIEW )
group by schm_code
我将从用户输入中获取输入,我不希望括号中的 select 语句,我需要为其中的所有内容返回一个值,例如:
select distinct SCHM_CODE,
sum(DEP_AMT) as AMOUNT
from DLY_DEP_VIEW
where Schm_code in (ALL_SCHM_CODES)
group by schm_code
这是给我无效的标识符:(编辑)
select distinct SCHM_CODE,
sum(DEP_AMT) as AMOUNT
from DLY_DEP_VIEW
where Schm_code in (select regexp_substr('" + c + "', '[^,]+',1,level) p
from dual t
connect by level <= regexp_count('" + c + "', ',') + 1
)
group by schm_code;
由于括号中的值在我的应用程序中不断变化。实现这一目标的最佳方法是什么?查询在 Java 代码中。