lintry

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

...@@ -35,12 +35,16 @@ module.exports = function (dbo) { ...@@ -35,12 +35,16 @@ module.exports = function (dbo) {
35 with days as ( 35 with days as (
36 select generate_series('2020-01-24'::date, CURRENT_DATE, '1 days')::date today 36 select generate_series('2020-01-24'::date, CURRENT_DATE, '1 days')::date today
37 ) 37 )
38 + , ta as (
39 + 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
40 + from tb_mf_timeline_area
41 + )
38 , stats as ( 42 , stats as (
39 - select country, province_short_name province, d.today, max(confirmed_count) confirmed_count 43 + select country, ta.province, d.today, max(confirmed_count) confirmed_count
40 from days d 44 from days d
41 - left join tb_mf_timeline_area ta on ta.update_time::date = d.today 45 + left join ta on ta.update_time::date = d.today and ta.rn = 1
42 where 1=1 46 where 1=1
43 - and province_name ~ :province 47 + and province ~ :province
44 group by 1,2,3 48 group by 1,2,3
45 order by 1,2,3 49 order by 1,2,3
46 ) 50 )
......