sql 问题!
id class_id user_id
1 2 3
2 2 3
3 2 2
4 1 2
结果
id class_id user_id
1 2 3
4 1 2
[解决办法]
select min(id),calss_id,max(user_id) from a group by class_id
[解决办法]
select id,distinct class_id ,user_id from aa
[解决办法]
select min(id),calss_id,user_id from aa where calss_id in (select distinct calss_id from aa)
[解决办法]
SELECT * FROM 表名 WHERE ID IN
(SELECT MAX(ID) AS ID FROM 表名
UNION
SELECT MIN(ID) AS ID FROM 表名
)