1 l00t 2020-12-29 23:18:37 +08:00 看不懂…… |
![]() | 2 wanv1171 2020-12-29 23:38:35 +08:00 先进行分组,然后用 over 选出每组最小的 B 。然后重新根据这个结果筛选 C IN (SELECT C) AND B IN (SELECT B),然后 GROUP BY C, GROUP_CONCAT(A) |
![]() | 3 wanv1171 2020-12-29 23:44:36 +08:00 via iPhone |
4 venhal 2020-12-29 23:44:55 +08:00 可以了解一下开窗函数,用 row_number()over()应该就可以满足 |
5 venhal 2020-12-29 23:52:46 +08:00 不过低版本的 mysql 好像不支持开窗函数,如果不支持的话 select t1.a, t2.b, t2.c from t1 join (select c, min(b) as b from t group by c) as t2 ON t1.c = t2.c AND t1.b = t2.b |
6 lybcyd 2020-12-30 11:22:10 +08:00 via Android 子查询吧,先用 c 分组,用 min 函数查出最小的 b 值,作为一个表 x,然后再查询大表中 b 和 c 等于 x 中 b 和 c 的记录 |
![]() | 8 liquorppp OP |
9 l00t 2020-12-30 12:26:15 +08:00 两个售价一样低的你打算怎么整。 |
![]() | 10 weiwenhao 2020-12-30 14:20:19 +08:00 select * from logs INNER JOIN (select MIN(id) as min_id FROM logs GROUP BY user_id) test on `test`.min_id = logs.id 类似这样? |
11 ZanderNg 2020-12-30 14:34:34 +08:00 select t1.* from (select t.a, t.b, t.c, row_number() over(partition by t.a order by to_number(b)) as rank from tgxt.test_a t where t.c is not null) t1 where rank = 1 |
14 xdwmxx 2020-12-30 20:35:20 +08:00 select * from (select t.A, t.B, t.C, row_number() over(partition by t.C order by t.B) rn from TEST_ROW_NUMBER_OVER t) where t.B is not null and rn = 1; 这样吗? |