代码
select * from grouptest,
(
select code, MAX(createtime) as tt from dbo.GroupTest
group by code
) main
where main.code = grouptest.code and main.tt = grouptest.createtime
group by id, grouptest.code
(
select code, MAX(createtime) as tt from dbo.GroupTest
group by code
) main
where main.code = grouptest.code and main.tt = grouptest.createtime
group by id, grouptest.code