【发布时间】:2021-11-10 22:31:09
【问题描述】:
user_id | sum | app_id | app_count
---------+------+--------+-----------
1 | 100 | 3 | 1
2 | 300 | 2 | 1
4 | 1100 | 1 | 2
4 | 1100 | 4 | 1
如何编写查询,以便根据 app_count 的等级选择不同的 user_id?
这是我想要的结果:
user_id | sum | app_id | app_count
---------+------+--------+-----------
1 | 100 | 3 | 1
2 | 300 | 2 | 1
4 | 1100 | 1 | 2
【问题讨论】:
-
重要细节:
app_count可以是NULL吗? -
不,不能为空
标签: sql postgresql window-functions