diff --git a/PostgreSQL/prism/prism.sql b/PostgreSQL/prism/prism.sql index d47bea1..50c46bc 100644 --- a/PostgreSQL/prism/prism.sql +++ b/PostgreSQL/prism/prism.sql @@ -9,3 +9,49 @@ from activities as a 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(activities.cause_id) +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;