如:从 group 为 1 、2 、3 的条件中查询 point 前 3 的项目的数据,这样就可以查询出 9 条数据了,能一条语句搞定吗?
如:从 group 为 1 、2 、3 的条件中查询 point 前 3 的项目的数据,这样就可以查询出 9 条数据了,能一条语句搞定吗?
|
ackolyNov 15, 2022 via iPhone
1
什么数据库,分析函数了解一下
|
|
optionalNov 15, 2022
2
row_number over partition by 一下,再套个子查询或者 cte ,完事
|
|
3
|
|
4
select * from table where group=1 order by point desc limit 3
union select * from table where group=2 order by point desc limit 3 union select * from table where group=3 order by point desc limit 3 |
|
dqzcwxbNov 15, 2022
5
并行查三次是最终答案
|
|
bugfanNov 15, 2022
7
老哥这头像真帅~~
|