Select top 10 RQ, LB, zsz, ltsz from hq_zqgm_scgm order by RQ
Industry ConversionCodeYes:
Select RQ, max (Case LB when 1 then zsz end) as zsz1, max (Case LB when 2 then zsz end) as zsz2
, Max (Case LB when 0 then zsz end) as zsz3
, Max (Case LB when 1 then ltsz end) as ltsz1, max (Case LB when 2 then ltsz end) as ltsz2
, Max (Case LB when 0 then ltsz end) as ltsz3
From hq_zqgm_scgm group by RQ order by RQ
Previous Code is hard to understand
Decomposition steps:
Select
Select RQ, (Case LB when 1 then zsz end) as zsz1, (Case LB when 2 then zsz end) as zsz2
, (Case LB when 0 then zsz end) as zsz3
, (Case LB when 1 then ltsz end) as ltsz1, (Case LB when 2 then ltsz end) as ltsz2
, (Case LB when 0 then ltsz end) as ltsz3
From hq_zqgm_scgm
Grouping value:
Select RQ, max (Case LB when 1 then zsz end) as zsz1, max (Case LB when 2 then zsz end) as zsz2
, Max (Case LB when 0 then zsz end) as zsz3
, Max (Case LB when 1 then ltsz end) as ltsz1, max (Case LB when 2 then ltsz end) as ltsz2
, Max (Case LB when 0 then ltsz end) as ltsz3
From hq_zqgm_scgm group by RQ order by RQ