Hive/Impala 改变 table 计数
Hive/Impala changing table counts
我有一个发布日期列表(一些过去和一些未来)和一个注册号列表。
release date registration
01/01/2019 R1
02/01/2019 R2
07/02/2019 R3
我基本上想创建一个新的 table 来显示每天(未来日期)的注册号码总数。
date total registration numbers
05/02/2019 2
06/02/2019 2
07/02/2019 3
我知道如何使用 count(*) 来查找注册数量,我考虑过将其与未来日期的日历 table 结合使用。
如果您有日历 table,您可以使用 window 功能:
select c.date,
count(t.date) as registrations_on_day,
sum(count(t.date)) over (order by c.date) as registrations_through_day
from calendar c left join
t
on c.date = t.date
group by c.date
order by c.date;
我有一个发布日期列表(一些过去和一些未来)和一个注册号列表。
release date registration
01/01/2019 R1
02/01/2019 R2
07/02/2019 R3
我基本上想创建一个新的 table 来显示每天(未来日期)的注册号码总数。
date total registration numbers
05/02/2019 2
06/02/2019 2
07/02/2019 3
我知道如何使用 count(*) 来查找注册数量,我考虑过将其与未来日期的日历 table 结合使用。
如果您有日历 table,您可以使用 window 功能:
select c.date,
count(t.date) as registrations_on_day,
sum(count(t.date)) over (order by c.date) as registrations_through_day
from calendar c left join
t
on c.date = t.date
group by c.date
order by c.date;