Как использовать Co связанных подзапросов в Oracle?
Привет всем, я пишу запрос для извлечения данных за предыдущий месяц и текущий месяц из одной таблицы.
но мой запрос дает ошибку
ORA-00979: not a GROUP BY expression 00979. 00000 - "not a GROUP BY expression" *Cause: *Action: Error at Line: 13 Column: 29
Если я использую эту комментируемую строку, то она выбрасывает эту ошибку на самом деле, чтобы подключиться
ecoll_lodg_prod_codeс базовым столом.
Что я уже пробовал:
select 1 user_id, t1.ecoll_cust_cr_acc_no "ACCOUNT_NUMBER", (case when t1.ecoll_lodg_prod_code='ENEFT' then 'NEFT' when t1.ecoll_lodg_prod_code='RTGS' then 'RTGS' when t1.ecoll_lodg_prod_code='IMPS' then 'IMPS' when t1.ecoll_lodg_prod_code='ERTGS' then 'RTGS' when t1.ecoll_lodg_prod_code='EFT' then 'FT' when t1.ecoll_lodg_prod_code='NEFT' then 'NEFT' end) "COLLECTION_MODE", (select sum(t2.ecoll_lodg_tran_amt) from ECOLL_LODG_VOL t2 where t2.ecoll_cust_cr_acc_no=t1.ecoll_cust_cr_acc_no and (trunc(t2.ecoll_lodg_date_time) between Last_Day(ADD_MONTHS(sysdate,-2))+1 and Last_Day(ADD_MONTHS(sysdate,-1))) and t2.ecoll_lodg_prod_code=t1.ecoll_lodg_prod_code ) "PREVIOUSVALUE", (select sum(ecoll_lodg_tran_amt) from ECOLL_LODG_VOL t where t.ecoll_cust_cr_acc_no=t1.ecoll_cust_cr_acc_no and trunc(t.ecoll_lodg_date_time) BETWEEN TRUNC (LAST_DAY (ADD_MONTHS (SYSDATE,-1))+ 1)AND TRUNC(SYSDATE) --and t.ecoll_lodg_prod_code=t1.ecoll_lodg_prod_code ) "CURRENTVALUE", (select count(t3.ecoll_lodg_tran_amt) from ECOLL_LODG_VOL t3 where t3.ecoll_cust_cr_acc_no=t1.ecoll_cust_cr_acc_no and (trunc(t3.ecoll_lodg_date_time) between Last_Day(ADD_MONTHS(sysdate,-2))+1 and Last_Day(ADD_MONTHS(sysdate,-1))) -- and t3.ecoll_lodg_prod_code=t1.ecoll_lodg_prod_code ) "PREVIOUSVOLUME", (select count(t4.ecoll_lodg_tran_amt) from ECOLL_LODG_VOL t4 where t4.ecoll_cust_cr_acc_no=t1.ecoll_cust_cr_acc_no and trunc(t4.ecoll_lodg_date_time) BETWEEN TRUNC (LAST_DAY (ADD_MONTHS (SYSDATE,-1))+ 1)AND TRUNC(SYSDATE) --and t4.ecoll_lodg_prod_code=t1.ecoll_lodg_prod_code )"CURRENTVOLUME" from ECOLL_LODG_VOL t1 where t1.ecoll_cust_cr_acc_no='111111111111111' group by 1, t1.ecoll_cust_cr_acc_no , (case when t1.ecoll_lodg_prod_code='ENEFT' then 'NEFT' when t1.ecoll_lodg_prod_code='RTGS' then 'RTGS' when t1.ecoll_lodg_prod_code='IMPS' then 'IMPS' when t1.ecoll_lodg_prod_code='ERTGS' then 'RTGS' when t1.ecoll_lodg_prod_code='EFT' then 'FT' when t1.ecoll_lodg_prod_code='NEFT' then 'NEFT' end);