lintry

取每日最新数据作为当天值

......@@ -35,12 +35,16 @@ module.exports = function (dbo) {
with days as (
select generate_series('2020-01-24'::date, CURRENT_DATE, '1 days')::date today
)
, ta as (
select country, province_short_name province, update_time, confirmed_count, row_number() over(partition by country, province_short_name order by update_time desc) rn
from tb_mf_timeline_area
)
, stats as (
select country, province_short_name province, d.today, max(confirmed_count) confirmed_count
select country, ta.province, d.today, max(confirmed_count) confirmed_count
from days d
left join tb_mf_timeline_area ta on ta.update_time::date = d.today
left join ta on ta.update_time::date = d.today and ta.rn = 1
where 1=1
and province_name ~ :province
and province ~ :province
group by 1,2,3
order by 1,2,3
)
......