select name,sum(case when RN=1 then dim else 0 end ) 最大尺寸,
sum(case when RN=2 then dim else 0 end ) 第二大尺寸
from (
select
name
,row_number()over (partition by name order by dim desc) RN
,dim
from (
select name ,dim1 dim from table
union all
select name ,dim2 dim from table
union all
select name ,dim3 dim from table)
)
group by name