left join ta on ta.update_time::date = d.today and ta.rn = 1
where 1=1
left join ta on ta.update_time = d.today
where country notnull
and province ~ :province
group by 1,2,3
order by 1,2,3
)
, pr as (
...
...
@@ -61,6 +64,7 @@ module.exports = function (dbo) {
, rpt as (
select country, province, today, confirmed_count, confirmed_count - COALESCE(lag(confirmed_count) over(partition by country, province order by today), 0) increase
select country, province, max(confirmed_count) max_count, jsonb_agg(today order by today) days, jsonb_agg(confirmed_count order by today) confirmed_counts,
jsonb_agg(increase order by today) increase,
max(confirmed_sum) confirmed_sum
from ( select *, sum(confirmed_count) over(partition by country, today) confirmed_sum from rpt
select country, '全国' province, max(confirmed_sum) max_count, jsonb_agg(today order by today) days, jsonb_agg(confirmed_sum order by today) confirmed_counts,