Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

SAMPLE QUERY

Yukihiro Okada edited this page May 24, 2018 · 2 revisions
presto:audit> SELECT date_add('DAY', x, date '2018-01-01') FROM UNNEST("sequence"(0, 36, 1)) "T1" (x);
   _col0
------------
 2018-01-01
 2018-01-02
 2018-01-03
 2018-01-04
 2018-01-05
 2018-01-06
 2018-01-07
 2018-01-08
 2018-01-09
 2018-01-10
 2018-01-11
 2018-01-12
 2018-01-13
 2018-01-14
 2018-01-15
 2018-01-16
 2018-01-17
 2018-01-18
 2018-01-19
 2018-01-20
 2018-01-21
 2018-01-22
 2018-01-23
 2018-01-24
 2018-01-25
 2018-01-26
 2018-01-27
 2018-01-28
 2018-01-29
 2018-01-30
 2018-01-31
 2018-02-01
 2018-02-02
 2018-02-03
 2018-02-04
 2018-02-05
 2018-02-06
(37 rows)

Query 20180524_153426_00060_wuj8w, FINISHED, 1 node
Splits: 17 total, 17 done (100.00%)
0:00 [0 rows, 0B] [0 rows/s, 0B/s]
WITH X AS ( 
  SELECT CAST( REPLACE(CAST(date_add('DAY', x, date '2018-01-01') AS VARCHAR), '-') AS BIGINT) AS c1 FROM UNNEST("sequence"(0, 36, 1)) "T1" (x) 
),
Y AS (
  SELECT ss.ymd, COUNT(*) AS count FROM ss JOIN X ON X.c1 = ss.ymd GROUP BY ss.ymd
)
  SELECT * FROM Y;
Clone this wiki locally