求助大哥們這個陳述句怎么寫。
要求--參加過城鄉居民養老保險的60歲以上人口無養老保險金
表1:PKRKXX (人資訊表) 欄位1:sf_ylbx (是否參加養老保險 ,值(是,否)),欄位2:id(身份證號碼),欄位3:戶編號(h_id)
表2:PKHXX(戶資訊表) 欄位1:ylbxj(養老保險金),欄位2:戶編號(h_id)
希望大哥們教一下查詢和統計。

我寫不對啊。腦子沒有饒清楚哎。。
select * from(select PKRKXX.h_id,count(case when PKRKXX.sf_ylbx='是' and 2020-substr(PKRKXX.id,7,4)>=60 then 1 else null end)as Pkhbh from PKRKXX group by h_id) where h_id>0 and PKRKXX.h_id=PKHXX.h_id and ylbxj=0
select count(*) from(select PKRKXX.h_id,count(case when PKRKXX.sf_ylbx='是' and 2020-substr(PKRKXX.id,7,4)>=60 then 1 else null end)as Pkhbh from PKRKXX group by h_id) where h_id>0 and PKRKXX.h_id=PKHXX.h_id and ylbxj=0
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/225658.html
標籤:基礎和管理
上一篇:Oracle 11g ORA-01792 如何去掉不超出1000列的限制
下一篇:新手學oracle
