Admin (ID: 1)
头衔:论坛坛主
等级:究级天王[荣誉]
积分:231
发帖:14 篇
来自:保密
注册:2023-03-11 15:22:38
造访:2025-11-10 11:21:39
[ 第 1 楼 ]
回复
查询跳板编号
select distinct a.courtid, b.courtname, (regexp_matches(a.apiurl, '(\d+)80'))[1]::integer tn, b.state
from place a left join court b on b.courtid=a.courtid order by tn
统计标注后的球队得分
select b.nick, a.score from(
select teamid, sum(case offensive when 'free' then 1
when 'far' then 3 else 2 end*cnt) as score from(
select teamid, offensive, count(0) as cnt
from notify where actid=93 and state=1 and jieguo='goal'
group by teamid, offensive
) a group by teamid
) a left join teams b on b.teamid=a.teamid

2023-06-07 23:20:01

IP:已设置保密
Admin (ID: 1)
头衔:论坛坛主
等级:究级天王[荣誉]
积分:231
发帖:14 篇
来自:保密
注册:2023-03-11 15:22:38
造访:2025-11-10 11:21:39
[ 第 2 楼 ]
回复
select a.*, b.offensive, d.nick as teamname, c.remark, e.jersey, b.starid, b.teamid
from calc_shot(92) a
left join notify b on b.notid=a.notid
left join stars c on c.starid=b.starid
left join teams d on d.teamid=b.teamid
left join teamusers e on e.teamid=b.teamid and e.starid=b.starid
where b.state=1

2023-06-07 23:20:28

IP:已设置保密
Admin (ID: 1)
头衔:论坛坛主
等级:究级天王[荣誉]
积分:231
发帖:14 篇
来自:保密
注册:2023-03-11 15:22:38
造访:2025-11-10 11:21:39
[ 第 3 楼 ]
回复
添加虚拟列
alter table clip_tasks add column starid integer generated always as (
case when kind=1 then refid when tempname in ('得分王集锦', '得分王集锦(速览版)') then
substring(result->>'attach' from '\d+$')::integer else 0 end
) stored

2023-08-28 15:55:49

IP:已设置保密
Admin (ID: 1)
头衔:论坛坛主
等级:究级天王[荣誉]
积分:231
发帖:14 篇
来自:保密
注册:2023-03-11 15:22:38
造访:2025-11-10 11:21:39
[ 第 4 楼 ]
回复
SQLite 以及 PgSQL 多表更新:
update notify AS a
set participants=json_set(a.participants, '$[0].playerid', b.playerid)
from uprows b where a.eventid=b.eventid

2023-10-31 18:34:16

IP:已设置保密
Admin (ID: 1)
头衔:论坛坛主
等级:究级天王[荣誉]
积分:231
发帖:14 篇
来自:保密
注册:2023-03-11 15:22:38
造访:2025-11-10 11:21:39
[ 第 5 楼 ]
回复
同步导入生涯纪录
with allbind as (
-- 已绑定的球星
select uid, starid from stars where uid>0
),
allclaim as (
-- 有认领记录的 5v5 球星
select claid, uid, (ext->>'starid')::integer starid from claim_shot where kind=0
),
unbind as (
-- 尚未认领的 5v5 球星
select a.* from allbind a
left join allclaim b on b.uid=a.uid and b.starid=a.starid
where b.claid is null
),
allnews as (
-- 所有需要同步的数据
select a.uid, c.courtid, c.placeid, c.actdate playday, 0 kind,
jsonb_build_object(
'actid', b.actid, 'starid', b.starid, 'shots', b.shots, 'team', d.nick,
'jersey', b.jersey, 'icon', b.bodyimg, 'score', b.score
) ext
from unbind a left join teamusers b on b.starid=a.starid
left join activity c on c.actid=b.actid left join teams d on d.teamid=b.teamid
)
-- insert into claim_shot(uid, courtid, placeid, playday, kind, ext)
select * from allnews where courtid>0

2023-11-20 11:44:44

IP:已设置保密
Admin (ID: 1)
头衔:论坛坛主
等级:究级天王[荣誉]
积分:231
发帖:14 篇
来自:保密
注册:2023-03-11 15:22:38
造访:2025-11-10 11:21:39
[ 第 6 楼 ]
回复
-- 统计场馆 11月份
with zhifu as (
select fee, refid, api from payment
where paytime between '2023-11-01 00:00:00' and '2023-12-01 00:00:00'
)
-- 球星二合一
select '运镜合成' kind, round(sum(a.fee)::numeric/100, 2) total
from zhifu a left join act5v5_star_order b on b.ordid=a.refid
left join activity c on c.actid=b.actid
where a.api='UnlockStar' and c.courtid=5 union
-- 球星集锦
select '球星集锦' kind, round(sum(a.fee)::numeric/100, 2) total
from zhifu a left join act5v5_fusion_order b on b.ordid=a.refid
left join activity c on c.actid=b.actid
where a.api='UnlockStarFusion' and c.courtid=5 union
-- 球队集锦
select '球队集锦' kind, round(sum(a.fee)::numeric/100, 2) total
from zhifu a left join act5v5_team_order b on b.ordid=a.refid
left join activity c on c.actid=b.actid
where a.api='UnlockTeam' and c.courtid=5

2023-12-12 16:16:08

IP:已设置保密
Admin (ID: 1)
头衔:论坛坛主
等级:究级天王[荣誉]
积分:231
发帖:14 篇
来自:保密
注册:2023-03-11 15:22:38
造访:2025-11-10 11:21:39
[ 第 7 楼 ]
回复
支付排名
with paytop as (
select uid, count(0) paynum, round(sum(fee)/100.00, 2) payfee, max(paytime) lasttime, min(paytime) mintime
from payment group by uid order by payfee desc limit 50
)
select a.*, b.nick, b.phone from paytop a
left join users b on b.uid=a.uid order by a.payfee desc

2024-01-26 12:05:24

IP:已设置保密
Admin (ID: 1)
头衔:论坛坛主
等级:究级天王[荣誉]
积分:231
发帖:14 篇
来自:保密
注册:2023-03-11 15:22:38
造访:2025-11-10 11:21:39
[ 第 8 楼 ]
回复
所有场馆统计
with courtact as (
select a.actid, a.actdate, a.courtid, b.public1+b.public2>0 as haspub
from activity a left join act5v5 b on b.actid=a.actid
where a.state>0
),
fenxi as (
select a.courtid, current_date - min(a.actdate) 上线天数,
count(distinct a.actid) 分析场次, count(distinct b.teamid) 队伍数,
count(distinct starid) 球员数
from courtact a left join teamusers b on b.actid=a.actid
where b.score>0 group by a.courtid
),
unlockdata as (
-- 统计次数最多的一个月(月份丢失)
select courtid, max(num) 最高解锁 from (
-- 统计每月解锁量
select courtid, mon, count(0) num from (
-- 按月划分数据
select courtid, date_trunc('month', actdate) mon, haspub from courtact where haspub=true
) a group by courtid, mon
) a group by courtid
)
select d.courtname, b., c. from (
select distinct courtid from courtact
) a left join fenxi b on b.courtid=a.courtid
left join unlockdata c on c.courtid=a.courtid
left join court d on d.courtid=a.courtid

2024-02-06 11:01:06

IP:已设置保密
Admin (ID: 1)
头衔:论坛坛主
等级:究级天王[荣誉]
积分:231
发帖:14 篇
来自:保密
注册:2023-03-11 15:22:38
造访:2025-11-10 11:21:39
[ 第 9 楼 ]
回复
其他数据
with courtact as (
select a.actid, a.actdate, a.courtid, a.pv, b.teamid1, b.teamid2, b.public1+b.public2>0 haspub
from activity a left join act5v5 b on b.actid=a.actid
where a.state>0 and a.courtid=1 -- 此处指定场馆编号
),
topone as (
select a.courtid, a.actdate, c.nick 主队, d.nick 客队, e.nick 此球队, f.nick 球员, a.jersey 球衣, a.score 得分
from (
select a.courtid, a.actid, b.starid, b.teamid, b.score, a.actdate, b.jersey
from courtact a left join teamusers b on b.actid=a.actid
where b.score>0 order by b.score desc limit 1
) a left join act5v5 b on b.actid=a.actid
left join teams c on c.teamid=b.teamid1
left join teams d on d.teamid=b.teamid2
left join teams e on e.teamid=a.teamid
left join stars f on f.starid=a.starid
),
toppv as (
select a.courtid, a.actdate pv日期, a.pv, b.nick pv主队, c.nick pv客队
from courtact a left join teams b on b.teamid=a.teamid1
left join teams c on c.teamid=a.teamid2
order by a.pv desc limit 1
),
unlocked as (
select courtid, mon 解锁月, num 解锁次 from (
select courtid, mon, count(0) num from (
select courtid, date_trunc('month', actdate)::char(7) mon from courtact where haspub
) a group by courtid, mon order by num desc limit 1
) a
)
select d.courtname, a., b.*, c. from topone a left join toppv b on b.courtid=a.courtid
left join unlocked c on c.courtid=a.courtid
left join court d on d.courtid=a.courtid

2024-02-06 11:29:55

IP:已设置保密
Admin (ID: 1)
头衔:论坛坛主
等级:究级天王[荣誉]
积分:231
发帖:14 篇
来自:保密
注册:2023-03-11 15:22:38
造访:2025-11-10 11:21:39
[ 第 10 楼 ]
回复
查询 3 月份各场地 的收入:
with dates as (select '2024-03-01'::date sdate, '2024-04-01'::date edate),
pays as (
select payid, api, fee, paytime, refid from dates a
left join payment b on b.paytime between a.sdate and a.edate
and b.fee in (1500, 2500, 3500, 5000)
),
bycourt as (
-- api 为 CourtUnlockTeam,refid 为 app_op_log 的 logid,可以从 ids[2] 的 actid 关联到 placeid
select a.fee, c.placeid, case a.fee when 2500 then 2.0 else 1.0 end ver
from pays a left join app_op_log b on b.logid=a.refid
left join activity c on c.actid=b.ids[2]
where a.api='CourtUnlockTeam'
),
byteam as (
-- api 为 UnlockTeam,refid 为 act5v5_team_order 的 ordid,可以从 actid 关联到 placeid
select a.fee, c.placeid, case a.fee when 5000 then 2.0 else 1.0 end ver
from pays a left join act5v5_team_order b on b.ordid=a.refid
left join activity c on c.actid=b.actid
where a.api='UnlockTeam'
),
allver as (
-- 所有版本费用统计
select placeid, ver, sum(fee)/100 fee
from(
select * from bycourt union all
select * from byteam
) a group by placeid, ver
),
byver as (
-- 将 1.0 和 2.0 组合到一行
select z.placeid, a.fee fee1, b.fee fee2
from place z left join allver a on a.placeid=z.placeid and a.ver=1.0
left join allver b on b.placeid=z.placeid and b.ver=2.0
where z.state=1
),
actnums as (
-- 查询场地这个月的比赛数量
select a.placeid, count(b.actid) actnum
from dates, byver a left join activity b on b.placeid=a.placeid
where b.state>0 and b.actdate between dates.sdate and dates.edate
group by a.placeid
),
fusord as (
-- 查询集锦支付费用
select c.placeid, sum(b.fee/100) fusionfee
from dates a left join act5v5_fusion_order b on b.paytime between a.sdate and a.edate
left join activity c on c.actid=b.actid group by c.placeid
),
starord as (
-- 查询球星解锁支付费用
select c.placeid, sum(b.fee/100) unlockfee
from dates a left join act5v5_star_order b on b.paytime between a.sdate and a.edate
left join activity c on c.actid=b.actid group by c.placeid
)
select c.courtname, b.placename, a.*, d.actnum, f.unlockfee, e.fusionfee
from byver a left join place b on b.placeid=a.placeid
left join court c on c.courtid=b.courtid left join actnums d on d.placeid=a.placeid
left join fusord e on e.placeid=a.placeid left join starord f on f.placeid=a.placeid
order by a.fee1+coalesce(a.fee2, 0) desc

2024-04-03 20:33:34

IP:已设置保密
Admin (ID: 1)
头衔:论坛坛主
等级:究级天王[荣誉]
积分:231
发帖:14 篇
来自:保密
注册:2023-03-11 15:22:38
造访:2025-11-10 11:21:39
[ 第 11 楼 ]
回复
统计所有球队比赛及付费情况
with dates as (select '2024-01-01'::date sdate, '2024-05-01'::date edate),
allteam as (
-- 所有
select a.teamid, array_agg(b.courtname) courts, sum(actnum) actnum, max(lastid) lastid
from (
select a.teamid, c.courtid, count(c.actid) actnum, max(c.actid) lastid
from teams a left join act5v5 b on a.teamid in (b.teamid1, b.teamid2)
left join activity c on c.actid=b.actid
where c.state>0 group by a.teamid, c.courtid
) a left join court b on b.courtid=a.courtid group by a.teamid
),
pays as (
-- 指定时间段内的支付记录
select payid, api, fee, paytime, refid from dates a
left join payment b on b.paytime between a.sdate and a.edate
and b.api='UnlockTeam'
),
byteam as (
-- 球队各版本解锁费用
select b.teamid, a.fee, case b.skuid when 3 then 2.0 else 1.0 end ver
from pays a left join act5v5_team_order b on b.ordid=a.refid
),
sumfee as (
select teamid, ver, sum(fee/100) total from byteam group by teamid, ver
),
summem as (
select a.teamid, count(b.uid) memnum
from allteam a left join teammembs b on b.teamid=a.teamid and b.state=1
group by a.teamid
)
select e.nick, a.teamid, a.actnum, c.total total1, d.total total2,
coalesce(e.ext->>'hot', '0')::integer+e.pv hot, g.memnum, f.courtname, b.actdate, a.courts
from allteam a left join activity b on b.actid=a.lastid
left join sumfee c on c.teamid=a.teamid and c.ver=1.0
left join sumfee d on d.teamid=a.teamid and d.ver=2.0
left join teams e on e.teamid=a.teamid
left join court f on f.courtid=b.courtid
left join summem g on g.teamid=a.teamid
order by a.actnum desc

2024-04-14 18:07:39

IP:已设置保密
Admin (ID: 1)
头衔:论坛坛主
等级:究级天王[荣誉]
积分:231
发帖:14 篇
来自:保密
注册:2023-03-11 15:22:38
造访:2025-11-10 11:21:39
[ 第 12 楼 ]
回复
查询设备分布
select courtname, placename, array_to_string(aibox, '-') aibox, state from (
select b.courtname, a.placename, string_to_array(a.ext->>'aibox', '-') aibox, a.state from place a
left join court b on b.courtid=a.courtid
) a where aibox[3] is not null order by aibox[3]

2024-04-28 14:20:37

IP:已设置保密