with MiPriceTopOne as (select classid,max(dataTime) dataTime,max(id) as id from MiPrice group by classid)select * from MiPrice where id in (select id from MiPriceTopOne)