我有這樣的所有行從表中選擇值選取場:從表中的所有領域
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代碼中。
如果你能得到你必須將它傳遞給查詢莫名其妙用戶輸入?你如何得到這個輸入,你存儲哪些數據結構以及如何將它傳遞給查詢? – Ben
我得到它作爲字符串並將它傳遞給像查詢:'選擇不同SCHM_CODE,總和(DEP_AMT)從DLY_DEP_VIEW其中SCHM_CODE在(「‘+字符串+’」)GROUP BY SCHM_CODE' – ErrorNotFoundException
所以basicly你不AMOUNT在查詢中記錄一個IN語句? – Jester