Showing
1 changed file
with
16 additions
and
4 deletions
| ... | @@ -58,14 +58,26 @@ module.exports = function (dbo) { | ... | @@ -58,14 +58,26 @@ module.exports = function (dbo) { |
| 58 | select country, province, today, confirmed_count, confirmed_count - COALESCE(lag(confirmed_count) over(partition by country, province order by today), 0) increase | 58 | select country, province, today, confirmed_count, confirmed_count - COALESCE(lag(confirmed_count) over(partition by country, province order by today), 0) increase |
| 59 | from dat | 59 | from dat |
| 60 | ) | 60 | ) |
| 61 | + , summ as ( | ||
| 62 | + select country, today, sum(confirmed_count) confirmed_sum, sum(increase) increase | ||
| 63 | + from rpt | ||
| 64 | + group by 1,2 | ||
| 65 | + order by country, confirmed_sum desc | ||
| 66 | + ) | ||
| 61 | select country, province, max(confirmed_count) max_count, jsonb_agg(today) days, jsonb_agg(confirmed_count) confirmed_counts, | 67 | select country, province, max(confirmed_count) max_count, jsonb_agg(today) days, jsonb_agg(confirmed_count) confirmed_counts, |
| 62 | jsonb_agg(increase) increase, | 68 | jsonb_agg(increase) increase, |
| 63 | - max(confirmed_sum) confirmed_sum, | 69 | + max(confirmed_sum) confirmed_sum |
| 64 | - max(increase_sum) increase_sum | 70 | + from ( select *, sum(confirmed_count) over(partition by country, today) confirmed_sum from rpt |
| 65 | - from ( select *, sum(confirmed_count) over(partition by country, today) confirmed_sum, sum(increase) over(partition by country, today) increase_sum from rpt | ||
| 66 | ) t | 71 | ) t |
| 67 | group by 1,2 | 72 | group by 1,2 |
| 68 | - order by country, confirmed_counts desc | 73 | + union all |
| 74 | + select country, '全国' province, max(confirmed_sum) max_count, jsonb_agg(today) days, jsonb_agg(confirmed_sum) confirmed_counts, | ||
| 75 | + jsonb_agg(increase) increase, | ||
| 76 | + max(confirmed_sum) | ||
| 77 | + from summ | ||
| 78 | + where country = '中国' | ||
| 79 | + group by 1 | ||
| 80 | + order by country, max_count desc | ||
| 69 | `, {replacements: {province}, type: dbo.QueryTypes.SELECT}); | 81 | `, {replacements: {province}, type: dbo.QueryTypes.SELECT}); |
| 70 | 82 | ||
| 71 | return Result.Ok('成功!', result); | 83 | return Result.Ok('成功!', result); | ... | ... |
-
Please register or login to post a comment