根据字段去重查询所有数据

select distinct aa,* from TableInfo

where ID in (select MAX(ID) from TableInfogroup by aa)

 

 

 

select top 5 * from CH_PlanInfo left join CH_PlanTypeInfo on CH_PlanInfo.PlanTypeID=CH_PlanTypeInfo.PlanTypeID

where PlanID in (select MAX(PlanID) from CH_PlanInfo group by PlanCard)

posted @ 2015-06-08 12:24  shawli  阅读(726)  评论(0编辑  收藏  举报