0
次の結果を返すクエリがあります。Redshiftの日付範囲での塗りつぶし
select
trunc(t.created),
sum(count(*)) over (order by trunc(t.created) rows unbounded preceding) as cumulative_sales
from event e
LEFT JOIN person_tickets t on e.id = t.event_id
where event_id = 9999
group by trunc(t.created)
Date cumulative_bookings
2016-02-12 1
2016-02-18 3
2016-02-19 5
2016-02-20 352
2016-02-21 352
すべての日付が含まれるように日付シリーズに記入したいと思います。
2016-02-12 1
2016-02-13 1
2016-02-14 1
2016-02-15 1
2016-02-16 1
2016-02-17 1
2016-02-18 3
2016-02-19 5
2016-02-20 352
2016-02-21 352
は、私は私のために素敵な日付のシーケンスを生成しているコードに参加しようとしてきたが、私はどこかエレガントに参加するようにする方法を確認するために苦労しています。
select (
getdate()::date - row_number() over (order by true)
)::date as n
from event limit 500
は、以下のではなく、かなりそこ
CASE WHEN cumulative_bookings is null then LAG(cumulative_bookings IGNORE NULLS) OVER (ORDER BY n)
ELSE cumulative_bookings END as filled_cumulative_bookings