select 工号、卡号、消费时间 from A
where 消费时间 in (select max(消费时间) FROM A group by 工号)
得到每个工号最后一条消费记录
select * from a where exists (select 1 from (select 工号,max(消费时间) as 消费时间 group by 工号) as b where a.工号=b.工号 and a.消费时间=b.消费时间)
select top 1 * from 消费明细表 where 工号=工号 order by 消费时间 desc
select gonghao,kahao,max(xiaofeishijian) from A group by gonghao order by kahao