select a.* from Price  a,(select Name,max(Date) Date from Price group by Name) b where a.name = b.name order by a.name

解决方案 »

  1.   

    seelct * from  price a where not exists(select 1 from price b where a.name=b.name and a.date<b.date)
      

  2.   

    declare @price table (id int identity(1,1),name varchar(10),date datetime,bidprice float)insert into @price
    select 'aaa','2007-10-06',55
    union all
    select 'bbb','2007-02-06',50
    union all
    select 'aaa','2007-02-05',60
    union all
    select 'ccc','2007-02-05',35
    union all
    select 'ddd','2007-02-04',75
    union all
    select 'ccc','2007-02-04',40
    union all
    select 'ddd','2007-02-05',49select a.* from @price a,
    (select name,max(date) date from @price
    group by name) b
    where a.name=b.name
    and datediff(day,a.date,b.date)=0
      

  3.   

    select * from Price  a
    where not exits(select 1 from Price where a.name=name and time>a.time)
      

  4.   


    select * from price a where Date in(select max(Date) from price where name=a.name group by name)