server sql 分组取最大值
分组取最大值
select gr,num,dt,(select bys from test where gr=b.gr and dt=b.dt) bys
from
(
select gr,count(0) num,max(dt) dt from test group by gr
) b
分组取最大值
select gr,num,dt,(select bys from test where gr=b.gr and dt=b.dt) bys
from
(
select gr,count(0) num,max(dt) dt from test group by gr
) b