Prestoには、Histgram関数がありますが、返値がMap型になっています。 なので、その結果をどこかに書き出したいと思ってもイマイチ使いづらいです。 SELECT method, histogram(code) AS hist FROM www_access GROUP BY method こうしたときには、Mapの値を展開して、フラっトな形に直したいです。 そのためには、下記の関数を使います。 map_keys(x) map_values(x) https://prestodb.io/docs/current/functions/map.html unnest https://prestodb.io/docs/current/sql/select.html#unnest そんでもって、下のようなクエリを書きます。 With句のhist_tableでヒストグラムを作って、split