Files
fortern-sql-data/PostgreSQL/prism/prism.sql
2025-12-05 01:34:52 +08:00

95 lines
4.2 KiB
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;
-- 1天内的block-place行为按玩家分组
select cause_player_id, players.player, count(*)
from activities
left join players on activities.cause_player_id = players.player_id
where action_id = (select action_id from actions where action = 'block-place')
and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400
group by cause_player_id, player
order by count(cause_player_id) desc;
-- 1天内非明确实体触发的block-place行为
select *
from activities
where action_id = (select action_id from actions where action = 'block-place')
and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400
and cause_id is not null
limit 500;
-- 1天内非玩家触发的block-place行为按entity_type
select cause_entity_type_id, entity_type, count(*)
from activities
left join entity_types on activities.cause_entity_type_id = entity_types.entity_type_id
where action_id = (select action_id from actions where action = 'block-place')
and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400
and cause_player_id is null
group by cause_entity_type_id, entity_type
order by count(cause_entity_type_id) desc;
-- 1天内非明确实体触发的block-place行为按cause_id分组
select activities.cause_id, causes.cause, count(*)
from activities
left join causes on activities.cause_id = causes.cause_id
where action_id = (select action_id from actions where action = 'block-place')
and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400
and activities.cause_id is not null
group by activities.cause_id, causes.cause
order by count(activities.cause_id) desc;
-- 1天内nature引发的block-place事件按坐标分组并排序
select world_id, x, y, z, count((world_id, x, y, z))
from activities
where action_id = (select action_id from actions where action = 'block-place')
and cause_id = (select cause_id from causes where cause = 'nature')
and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400
group by world_id, x, y, z
order by count((world_id, x, y, z)) desc;
-- 1天内unknown 引发的 block-place 事件,按坐标分组并排序
select world_id, x, y, z, count((world_id, x, y, z))
from activities
where action_id = (select action_id from actions where action = 'block-place')
and cause_id = (select cause_id from causes where cause = 'unknown')
and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400
group by world_id, x, y, z
order by count((world_id, x, y, z)) desc;
-- 1天内的 block-break 行为按玩家分组
select cause_player_id, players.player, count(*)
from activities
left join players on activities.cause_player_id = players.player_id
where action_id = (select action_id from actions where action = 'block-break')
and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400
group by cause_player_id, player
order by count(cause_player_id) desc;
-- 1天内非玩家触发的 block-break 行为,按 cause_id 分组
select activities.cause_id, causes.cause, count(*)
from activities
left join causes on activities.cause_id = causes.cause_id
where action_id = (select action_id from actions where action = 'block-break')
and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400
and activities.cause_player_id is null
group by activities.cause_id, causes.cause
order by count(activities.cause_id) desc;
-- 1天内风弹实体触发的 block-break 行为,按坐标分组
select world_id, x, y, z, count((world_id, x, y, z))
from activities
where action_id = (select action_id from actions where action = 'block-break')
and cause_entity_type_id = (select entity_type_id from entity_types where entity_type = 'breeze_wind_charge')
and timestamp > EXTRACT(EPOCH FROM current_timestamp(0))::bigint - 86400
group by world_id, x, y, z
order by count((world_id, x, y, z)) desc;