sql行转列
with tt as( select 'A' product, 100 price, '2021第1季度' time union all select 'A' product, 777 price, '2021第1季度' time union all select 'A' product, 111 price, '2021第2季度' time union all select 'A' product, 222 price, '2021第2季度' time ) select '最大',* from tt pivot(max(price)for time in( [2021第2季度],[2021第1季度]) )a union all select '最小',* from tt pivot(min(price)for time in( [2021第2季度],[2021第1季度]) )a

浙公网安备 33010602011771号