by shigemk2

当面は技術的なことしか書かない

presto values

インクリメンタルなデータのインラインテーブルを作りたいんだけど、できないっぽい

ボイラープレートだな

SELECT * FROM (
  VALUES
    (DATE_FORMAT(DATE_ADD('day', -7, CAST(NOW() AT TIME ZONE 'Asia/Tokyo' AS DATE)), '%Y-%m-%d'), 1),
    (DATE_FORMAT(DATE_ADD('day', -6, CAST(NOW() AT TIME ZONE 'Asia/Tokyo' AS DATE)), '%Y-%m-%d'), 2),
    (DATE_FORMAT(DATE_ADD('day', -5, CAST(NOW() AT TIME ZONE 'Asia/Tokyo' AS DATE)), '%Y-%m-%d'), 3),
    (DATE_FORMAT(DATE_ADD('day', -4, CAST(NOW() AT TIME ZONE 'Asia/Tokyo' AS DATE)), '%Y-%m-%d'), 4),
    (DATE_FORMAT(DATE_ADD('day', -3, CAST(NOW() AT TIME ZONE 'Asia/Tokyo' AS DATE)), '%Y-%m-%d'), 5),
    (DATE_FORMAT(DATE_ADD('day', -2, CAST(NOW() AT TIME ZONE 'Asia/Tokyo' AS DATE)), '%Y-%m-%d'), 6),
    (DATE_FORMAT(DATE_ADD('day', -1, CAST(NOW() AT TIME ZONE 'Asia/Tokyo' AS DATE)), '%Y-%m-%d'), 7)
  ) AS t(date, count)

https://prestodb.io/docs/current/sql/values.htm