如:从 group 为 1 、2 、3 的条件中查询 point 前 3 的项目的数据,这样就可以查询出 9 条数据了,能一条语句搞定吗?
1
ackoly Nov 15, 2022 via iPhone
什么数据库,分析函数了解一下
|
2
optional Nov 15, 2022
row_number over partition by 一下,再套个子查询或者 cte ,完事
|
3
wolfie Nov 15, 2022 |
4
kwh Nov 15, 2022 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 |
5
dqzcwxb Nov 15, 2022
并行查三次是最终答案
|
7
bugfan Nov 15, 2022
老哥这头像真帅~~
|