12 lines
379 B
SQL
12 lines
379 B
SQL
-- 获取最新的数据
|
||
select max(timestamp)
|
||
from activities;
|
||
|
||
-- 1天内的数据,按action分组排序
|
||
select b.action_id, b.action, count(b.action_id)
|
||
from activities as a
|
||
left join actions as b on a.action_id = b.action_id
|
||
where timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 3600
|
||
group by b.action_id, b.action
|
||
order by count(b.action_id) desc;
|