select a.* from table a inner join 
(
select max(cast(djh as int)) as djh,ypdm from table group by ypdm
) b on cast(a.djh as int)=cast(b.djh as int) and a.ypdm=b.ypdm

解决方案 »

  1.   


    select * from 表 as AA where not exists(select 1 from 表 as BB where aa.ypdm=bb.ypdm and cast(aa.djh as int) <cast(bb.djh as int))
      

  2.   

    select * from table a where djh=(select max(djh) from table b where a.ypdm=b.ypdm)
      

  3.   

    select * from table a  inner join (select ypdm,max(djh) djh from table group by ypdm) b  on a.djh=b.djh)
      

  4.   

    select * from yourtable where cast(djh as int) in ( max(cast(djh as int)) from yourtable group by ypdm)
      

  5.   

    Select * from 表 a  where djh = (select max(djh) from 表 where ypdm = a.ypdm)
      

  6.   

    select max(djh),ypdm,mc from table group by ypdm,mc
      

  7.   

    select * from 表 tem where djh=(select max(djh) from 表 where ypdm=tem.ypdm)
      

  8.   


    select a.djh,a.ypdm,mc from 表 a right join (select max(djh) as djh,ypdm from 表 group by ypdm) b on a.djh=b.djh and a.ypdm=b.ypdm
      

  9.   

    select * from 表 where djh in (select max(djh) from 表 group by ypdm)