Home > database >  Turn to query and statistical statements
Turn to query and statistical statements

Time:11-21

How do you write this statement for help eldest brother,

- involved in urban and rural residents endowment insurance of population over the age of 60 no endowment insurance gold
Table 1: PKRKXX information table (people) field 1: sf_ylbx (whether attend endowment insurance, value (y, n)), field 2: id (id number), field 3: door number (h_id)
Table 2: PKHXX (table) household information field 1: ylbxj (endowment insurance), field 2: door number (h_id)
I hope eldest brother teach a query and statistics,

I don't write right ah, no RaoQingChu ah, brain,
Select * from (select PKRKXX h_id, count (case when PKRKXX. Sf_ylbx='is' and 2020 - substr (PKRKXX. Id, 7, 4) & gt; 60 then 1 else=null end) as Pkhbh from PKRKXX group by h_id) where h_id & gt; 0 and PKRKXX. H_id=PKHXX. H_id and ylbxj=0

Select count (*) from (the select PKRKXX h_id, count (case when PKRKXX. Sf_ylbx='is' and 2020 - substr (PKRKXX. Id, 7, 4) & gt; 60 then 1 else=null end) as Pkhbh from PKRKXX group by h_id) where h_id & gt; 0 and PKRKXX. H_id=PKHXX. H_id and ylbxj=0
  • Related