presto 实现 多行转多列

SELECT
  kv['20200101'] AS dt1,
  kv['20200102'] AS dt2,
  kv['20200103'] AS dt3
FROM (
  SELECT  map_agg(dt, cnt) kv
  FROM a
  GROUP BY 1
) t
 presto 实现 列转行

SELECT t1.uid, t2.key, t2.value
FROM a as t1 
CROSS JOIN unnest (
  array['dt1', 'dt2', 'dt3'],
  array[c1, c2, c3]
) t2 (key, value)
 

你可能感兴趣的:(大数据,hadoop)