select * from 表 a,(select VID,max(InputDay) InputDay from 表 group by VID) b where a.VID=b.VID and a.InputDay=b.InputDay

解决方案 »

  1.   

    VID    VName   State    Price          InputDayselect * from A A1
    where exists(select top 1 * from A A2
    where A1.VID<>A2.VID and A1.InputDay>A2.InputDay)
      

  2.   

    select
        a.*
    from
        表 a
    where
        not exists(select 1 from 表 where vid=a.vid and inputday>a.inputday)
      

  3.   

    select * from A A1
    where exists(select 1 from A A2
    where A1.VID<>A2.VID and A1.InputDay>A2.InputDay)
      

  4.   

    select * from tablename  as a
    where not exists (select 1
    from tablename as b where a.inputday>b.inoutday and a.vid = b.vid)
      

  5.   

    select t.*
    from yourtable t
    where not exists(select 1 from yourtable where vid=t.vid and inputday>t.inputday)
      

  6.   

    select * from @tab a,(select vid ,max(price)price from @tab group by vid)b
    where a.Price=b.price and a.vid=b.vid