· 6 years ago · Jun 16, 2019, 07:24 AM
1create table if not exists my_timeseries as
2 select
3 coalesce(sector, district, area) as postcode,
4 import_date,
5 'A'::character(1) as property_type,
6 -1::smallint as bedrooms,
7
8 CAST (sum(1) filter(where is_begin_ts) AS REAL) as s_listings,
9 CAST (percentile_cont(array[0.25,0.5,0.75,0.9]) within group (order by asking_price) filter(where asking_price > 0) AS REAL[]) as s_price_asked
10
11 from my_source_table
12 where import_date <= '2019-05-01'::date
13 grouping sets ((sector, import_date), (district, import_date), (area, import_date));