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