select * from tb a where not exists (select 1 from tb b where a.姓名=b.姓名 and a.时间<b.时间) order by 姓名
select * from (select FID,编号,时间,row_number() over(partition by FID order by 时间 desc) 最近一次时间 from A)Table where Table.最近一次时间=1 只能想到这个,测试了没问题
若FID跟姓名 是1对1 select FID,姓名,max(时间) as '最近登录时间' from 表A group by FID,姓名若FID跟姓名 是多对1关系,即FID类似于唯一主键 select a.FID,a.姓名,a.时间 as '最近登录时间' from 表A a ,(select 姓名, max(时间) as 时间 from 表A group by 姓名) b where a.姓名=b.姓名 and a.时间=b.时间
这个可以查找出来最近时间的,但是FID的顺序已经改变了,求FID不要改变位置、
手写的 select * from A as t1 inner join (select 姓名,max(时间) as 时间 from A group by 姓名) as t2 on t1.姓名=t2.姓名 and t1.时间=t2.时间
测试了,这样会多列,还有同样改变FID位置
select FID,姓名,时间from A as t1 inner join (select 姓名,max(时间) as 时间 from A group by 姓名) as t2 on t1.姓名=t2.姓名 and t1.时间=t2.时间 order by t1.FID
select * from aa a where not exists (select 1 from aa b where a.编号=b.编号 and a.时间<b.时间)
加上表名啥 select t1.FID,t1.姓名,t1.时间 from A as t1 inner join (select 姓名,max(时间) as 时间 from A group by 姓名) as t2 on t1.姓名=t2.姓名 and t1.时间=t2.时间 order by t1.FID
select a1.fid,a1.name,a1.dtime from A as a1 inner join (select name,max(dtime) maxtime from A group by name) as a2 on a1.name = a2.name and a1.dtime=a2.maxtime 貌似好12楼一样,那就当给12楼+1
select * from (select FID,编号,时间,row_number() over(partition by FID order by 时间 desc) 最近一次时间 from A)Table where Table.最近一次时间=1 只能想到这个,测试了没问题
select FID,姓名,max(时间) as '最近登录时间' from 表A group by FID,姓名若FID跟姓名 是多对1关系,即FID类似于唯一主键
select a.FID,a.姓名,a.时间 as '最近登录时间' from 表A a ,(select 姓名, max(时间) as 时间 from 表A group by 姓名) b where a.姓名=b.姓名 and a.时间=b.时间
select * from A as t1
inner join (select 姓名,max(时间) as 时间 from A group by 姓名) as t2
on t1.姓名=t2.姓名 and t1.时间=t2.时间
inner join (select 姓名,max(时间) as 时间 from A group by 姓名) as t2
on t1.姓名=t2.姓名 and t1.时间=t2.时间 order by t1.FID
select * from aa a where not exists (select 1 from aa b where a.编号=b.编号 and a.时间<b.时间)
select t1.FID,t1.姓名,t1.时间 from A as t1
inner join (select 姓名,max(时间) as 时间 from A group by 姓名) as t2
on t1.姓名=t2.姓名 and t1.时间=t2.时间 order by t1.FID
(select name,max(dtime) maxtime from A group by name) as a2
on a1.name = a2.name and a1.dtime=a2.maxtime 貌似好12楼一样,那就当给12楼+1