Example1:
part of table test1:
name|mygroup| scale
----------------
ben | 1 | 1
tom | 1 | 2
jim | 2 | 1
tim | 2 | 2
..
the output should be:
name|mygroup| scale
----------------
ben | 1 | 1
jim | 2 | 1
I try:
select name,mygroup,min(scale) from test1 group by mygroup;
but it not give proper output.
Thanks
SELECT t.name, t.mygroup, t.scale
FROM test1 t
INNER JOIN (SELECT mygroup, MIN(scale) AS MinScale
FROM test1
GROUP BY mygroup) q
ON t.mygroup = q.mygroup
AND t.scale = q.MinScale
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.