Files
youlegames/codes/games/sql/game/scripts/room_players.sql

50 lines
2.5 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.
-- ============================================================
-- 脚本名称: room_players.sql
-- 功 能: 查询指定房间号的所有历史对局及每局玩家信息
-- 数据库 : grade_db + game_db跨库同一RDS实例
-- RDS: rm-bp1749tfxu2rpq670lo
-- 说明 :
-- 同一房间号可能在不同时间出现多次,结果按开房时间分组。
-- 输出按「开房时间 DESC → 得分 DESC」排序
-- 相同开房时间的行即为同一场对局,可在结果中直接区分。
-- ============================================================
-- ============================================================
-- 【参数设置】 ← 修改这里
-- ============================================================
SET @p_agentid = 'veRa0qrBf0df2K1G4de2tgfmVxB2jxpv'; -- 代理商ID
SET @p_roomcode = 0; -- 房间号plgr_roomcode
-- ============================================================
-- 【查询】指定房间号的所有历史对局玩家明细
-- 结果按开房时间倒序排列,同一开房时间为同一场对局
-- ============================================================
SELECT
DATE_FORMAT(pg.plgr_createtime, '%Y-%m-%d %H:%i:%s') AS '创建时间',
DATE_FORMAT(pg.plgr_overtime, '%Y-%m-%d %H:%i:%s') AS '结束时间',
pg.plgr_roomcode AS '房间号',
pg.plgr_playerid AS '玩家ID',
p.play_nickname AS '玩家昵称',
pg.plgr_score AS '得分',
pg.plgr_winner AS '是否大赢家1=是)',
pg.plgr_deductcard AS '扣除房卡',
DATE_FORMAT(pg.plgr_makewartime, '%Y-%m-%d %H:%i:%s') AS '开战时间',
pg.plgr_roomtype AS '房间类型',
pg.plgr_gameid AS '游戏ID',
g.game_name AS '游戏名称'
FROM
grade_db.player_grade pg
LEFT JOIN game_db.player p
ON pg.plgr_agentid = p.play_agentid
AND pg.plgr_playerid = p.play_playerid
LEFT JOIN game_db.game g
ON pg.plgr_gameid = g.game_gameid
WHERE
pg.plgr_agentid = @p_agentid
AND pg.plgr_roomcode = @p_roomcode
ORDER BY
pg.plgr_createtime DESC,
pg.plgr_score DESC;