用case when 处理 select max(case when cdxh=1 then pz end ) as pz1, max(case when cdxh=1 then fsts end ) as fsts1, max(case when cdxh=1 then yzsl end ) as yzsl1, max(case when cdxh=2 then pz end ) as pz2, max(case when cdxh=2 then fsts end ) as fsts2, max(case when cdxh=2 then yzsl end ) as yzsl2, max(case when cdxh=3 then pz end ) as pz3, max(case when cdxh=3 then fsts end ) as fsts3, max(case when cdxh=3 then yzsl end ) as yzsl3, ................. from tableName group by jh
select jh, max(case when cdxh=1 then pz end ) as pz1, max(case when cdxh=1 then fsts end ) as fsts1, max(case when cdxh=1 then yzsl end ) as yzsl1, max(case when cdxh=2 then pz end ) as pz2, max(case when cdxh=2 then fsts end ) as fsts2, max(case when cdxh=2 then yzsl end ) as yzsl2, max(case when cdxh=3 then pz end ) as pz3, max(case when cdxh=3 then fsts end ) as fsts3, max(case when cdxh=3 then yzsl end ) as yzsl3, max(case when cdxh=4 then pz end ) as pz4, max(case when cdxh=4 then fsts end ) as fsts4, max(case when cdxh=4 then yzsl end ) as yzsl4 from tableName group by jh
select
max(case when cdxh=1 then pz end ) as pz1,
max(case when cdxh=1 then fsts end ) as fsts1,
max(case when cdxh=1 then yzsl end ) as yzsl1,
max(case when cdxh=2 then pz end ) as pz2,
max(case when cdxh=2 then fsts end ) as fsts2,
max(case when cdxh=2 then yzsl end ) as yzsl2,
max(case when cdxh=3 then pz end ) as pz3,
max(case when cdxh=3 then fsts end ) as fsts3,
max(case when cdxh=3 then yzsl end ) as yzsl3,
.................
from tableName
group by jh
jh,
max(case when cdxh=1 then pz end ) as pz1,
max(case when cdxh=1 then fsts end ) as fsts1,
max(case when cdxh=1 then yzsl end ) as yzsl1,
max(case when cdxh=2 then pz end ) as pz2,
max(case when cdxh=2 then fsts end ) as fsts2,
max(case when cdxh=2 then yzsl end ) as yzsl2,
max(case when cdxh=3 then pz end ) as pz3,
max(case when cdxh=3 then fsts end ) as fsts3,
max(case when cdxh=3 then yzsl end ) as yzsl3,
max(case when cdxh=4 then pz end ) as pz4,
max(case when cdxh=4 then fsts end ) as fsts4,
max(case when cdxh=4 then yzsl end ) as yzsl4
from tableName
group by jh