Files
fortern-sql-data/PostgreSQL/prism/prism.sql
2025-12-02 19:31:05 +08:00

12 lines
380 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 获取最新的数据
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 - 86400
group by b.action_id, b.action
order by count(b.action_id) desc;