select case
The when t.n l & lt; 30 then
'30 years old the following (not including 30)
The when t.n l & gt;=30 and t.n l & lt; 35 then=
'30-35'
The when t.n l & gt;=36 and t.n l & lt; 40 then=
'36 to 40'
The when t.n l & gt;=41 and t.n l & lt; 45 then=
'41-45'
The when t.n l & gt;=46 and t.n l & lt;=50 then
'46-50'
The when t.n l & gt; 51 and t.n=l & lt;=55 then
'51 and 55'
The when t.n l & gt;=56 and t.n l & lt; 60 then=
'56-60'
The when t.n l & gt;=61 and t.n l & lt; Then=65
'61-65
The when t.n l & gt;=66 and t.n l & lt; Then=69
'66-69
The when t.n l & gt; Then=70
'more than 70 (including 70)
End as lx,
Count (1) the as sumper
The from (select rownum,
T1 zjkid,
T1 ZJXM,
(SELECT floor (MONTHS_BETWEEN (
To_date (to_char (sysdate, 'MM - dd yyyy -'), '- dd yyyy - MM),
To_date (t1) csny, 'yyyy - MM - dd)
)/12)
The from dual) as nl,
T1 LXSJ,
T1 GZDW,
T1 WHCD,
T1 sxzy,
T1 cyqssj,
(select y.z y from zjk_zy y where y.z ylb='0' and y.i d=t1. Zczy) as zczy,
(select cc. Code_name
The from unieap up_codelist_code cc, unieap. Up_codelist c
Where cc. Codelist_id=Arthur c. odelist_id
And cc. Code=t1. Zczydj
And Arthur c. ode='ZCDJ'
And rownum=1) as zczydj,
(select y.z y from zjk_zy y where y.z ylb='1' and y.i d=t1. Zyfx) as zyfx
The from v_gs_pszj t1 where 1=1
) t
Group by case
The when t.n l & lt; 30 then
'30 years old the following (not including 30)
The when t.n l & gt;=30 and t.n l & lt; 35 then=
'30-35'
The when t.n l & gt;=36 and t.n l & lt; 40 then=
'36 to 40'
The when t.n l & gt;=41 and t.n l & lt; 45 then=
'41-45'
The when t.n l & gt;=46 and t.n l & lt;=50 then
'46-50'
The when t.n l & gt; 51 and t.n=l & lt;=55 then
'51 and 55'
The when t.n l & gt;=56 and t.n l & lt; 60 then=
'56-60'
The when t.n l & gt;=61 and t.n l & lt; Then=65
'61-65
The when t.n l & gt;=66 and t.n l & lt; Then=69
'66-69
The when t.n l & gt; Then=70
'more than 70 (including 70)
End
The order by lx asc
CodePudding user response:
The when t.n l & lt; 30 then'30 years old the following (not including 30)
The when t.n l & gt;=30 and t.n l & lt; 35 then=
'30-35'
The when t.n l & gt;=36 and t.n l & lt; 40 then=
'36 to 40'
The when t.n l & gt;=41 and t.n l & lt; 45 then=
'41-45'
The when t.n l & gt;=46 and t.n l & lt;=50 then
'46-50'
The when t.n l & gt; 51 and t.n=l & lt;=55 then
'51 and 55'
The when t.n l & gt;=56 and t.n l & lt; 60 then=
'56-60'
The when t.n l & gt;=61 and t.n l & lt; Then=65
'61-65
The when t.n l & gt;=66 and t.n l & lt; Then=69
'66-69
The when t.n l & gt; Then=70
'more than 70 (including 70)
These data, alone on a table, table called t
Query, use left to join
CodePudding user response:
Select sum (case when t.n l & lt; 30 then 1 else 0 end) 30,The sum (case when t.n l & gt; 30 and t.n l & lt; 40 then 1 else 0=end) 30 to 40,
The sum (case when t.n l & gt; 40 and t.n l & lt;=50 then 1 else 0 end) forty to fifty,
The sum (case when t.n l & gt; Over 50 then 1 else 0 end)
The from
(select trunc (to_char (sysdate, 'yyyymmdd') - to_char (substr (' 341233197612158111 ', 7, 8)))/10000 nl
The from dual t1) t;
This is a line showing all, you need to list the form, can again under the transformation
CodePudding user response:
In advance plus a countCodePudding user response: