-7
select name,value from (
select name,value from
(
select 'WHB' name,count(*) value from bld_comp_prep where bld_comp_code ='WHB' and comp_code =:a_bld_user_comp and nvl(status,'S')='S' and nvl(delete_flag,'N') ='N'
union all
select 'RBC' name,count(*) value from bld_comp_prep where bld_comp_code ='RBC' and comp_code =:a_bld_user_comp and nvl(status,'S')='S' and nvl(delete_flag,'N') ='N'
union all
select 'FFP' name,count(*) value from bld_comp_prep where bld_comp_code ='FFP' and comp_code =:a_bld_user_comp and nvl(status,'S')='S' and nvl(delete_flag,'N') ='N'
union all
select 'PLC' name,count(*) value from bld_comp_prep where bld_comp_code ='PLC' and comp_code =:a_bld_user_comp and nvl(status,'S')='S' and nvl(delete_flag,'N') ='N'
union all
select 'CRY' name,count(*) value from bld_comp_prep where bld_comp_code ='CRY' and comp_code =:a_bld_user_comp and nvl(status,'S')='S' and nvl(delete_flag,'N') ='N'
union all
select 'GRC' name,count(*) value from bld_comp_prep where bld_comp_code ='GRC' and comp_code =:a_bld_user_comp and nvl(status,'S')='S' and nvl(delete_flag,'N') ='N'
)
left JOIN (
select name,value from(
select 'WHB' name, count(*) value from bld_issue_dtl dtl,bld_issue_hdr hdr,bld_comp_prep prep where prep.bld_comp_code ='WHB' and hdr.issue_code =dtl.issue_code and hdr.comp_code =dtl.comp_code and dtl.comp_bag_code =prep.comp_bag_code and dtl.comp_code =prep.comp_code and TO_DATE(hdr.issue_date,'DD-MON-YY') =TO_DATE(:P29_STOCK_DATE,'DD-MON-YY')
union all
select 'RBC' name, count(*) value from bld_issue_dtl dtl,bld_issue_hdr hdr,bld_comp_prep prep where prep.bld_comp_code ='RBC' and hdr.issue_code =dtl.issue_code and hdr.comp_code =dtl.comp_code and dtl.comp_bag_code =prep.comp_bag_code and dtl.comp_code =prep.comp_code and TO_DATE(hdr.issue_date,'DD-MON-YY') =TO_DATE(:P29_STOCK_DATE,'DD-MON-YY')
union all
select 'FFP' name, count(*) value from bld_issue_dtl dtl,bld_issue_hdr hdr,bld_comp_prep prep where prep.bld_comp_code ='FFP' and hdr.issue_code =dtl.issue_code and hdr.comp_code =dtl.comp_code and dtl.comp_bag_code =prep.comp_bag_code and dtl.comp_code =prep.comp_code and TO_DATE(hdr.issue_date,'DD-MON-YY') =TO_DATE(:P29_STOCK_DATE,'DD-MON-YY')
union all
select 'PLC' name, count(*) value from bld_issue_dtl dtl,bld_issue_hdr hdr,bld_comp_prep prep where prep.bld_comp_code ='PLC' and hdr.issue_code =dtl.issue_code and hdr.comp_code =dtl.comp_code and dtl.comp_bag_code =prep.comp_bag_code and dtl.comp_code =prep.comp_code and TO_DATE(hdr.issue_date,'DD-MON-YY') =TO_DATE(:P29_STOCK_DATE,'DD-MON-YY')
union all
select 'CRY' name, count(*) value from bld_issue_dtl dtl,bld_issue_hdr hdr,bld_comp_prep prep where prep.bld_comp_code ='CRY' and hdr.issue_code =dtl.issue_code and hdr.comp_code =dtl.comp_code and dtl.comp_bag_code =prep.comp_bag_code and dtl.comp_code =prep.comp_code and TO_DATE(hdr.issue_date,'DD-MON-YY') =TO_DATE(:P29_STOCK_DATE,'DD-MON-YY')
union all
select 'GRC' name, count(*) value from bld_issue_dtl dtl,bld_issue_hdr hdr,bld_comp_prep prep where prep.bld_comp_code ='GRC' and hdr.issue_code =dtl.issue_code and hdr.comp_code =dtl.comp_code and dtl.comp_bag_code =prep.comp_bag_code and dtl.comp_code =prep.comp_code and TO_DATE(hdr.issue_date,'DD-MON-YY') =TO_DATE(:P29_STOCK_DATE,'DD-MON-YY')
)));
這不是問題。問題以字符'?'結尾。我不知道你的意思是「將這兩個選擇列表相互添加」。 –
問題不明確。你可能想看看[mcve]來建立一個例子並澄清你的問題。事實上,我相信這個問題很快就會結束。 – Aleksej
我注意到兩件事:1)你的內部查詢可以只是一個帶有GROUP BY的查詢,2)你應該使用'JOIN'而不是SELECT ... FROM x,y WHERE ...在這些被修復之後,看看是否連接兩個表的正確連接並不清晰。 –