我使用以下查询过滤 My (TableA - fields app_id, user_id, points, tr_type, description )
select app_id, user_id,sum(case when tr_type = 'add' then points when tr_type = 'sub' then - points end) as points
from TableA
group by app_id, user_id;
结果:
app_id user_id points
1 1a 10
1 1b 12
1 1c 3
现在我有另一张桌子(TableB)
app_id user_id points desc
1 1a 0 text
1 1b 0 tet
1 1c 0 txt
现在我需要快速替换查询来更新 TableB 点值,它是来自 TableA 的 groupby