一,看原表

select * from `user`;

二,查询同组年级最大的

select 
username
,SUBSTRING_INDEX( GROUP_CONCAT(age order by age desc) ,',',1) uuid 
from 
(
    select uuid
	,username
	,`password`
	,age
    from `user`
)b 
GROUP BY uuid asc;

第二种:

select  *
from user
where (CreateTime,userId) in 
	  (select max(CreateTime),userId from user group by userId);

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐