【发布时间】:2021-05-19 06:59:38
【问题描述】:
我有一个事务表(“TableA”),在 TableA 中有这些字段 app_id、user_id、points、tr_type、description。所以在事务中有加减tr_type是有的。现在我想根据 tr_type 获取 user_id 的 total_points (points = added-subtract)。为此我需要如何编写 MySQL 查询>
对于类型是添加或子。
所以现在我想要这 3 个字段的 GroupBY --> app_id、user_id、points
【问题讨论】:
-
请提供样本数据和所需结果。