select 客户,日期,资金 from 客户资金表 as X where 日期 in (select top 1 日期 from 客户资金表 as Y where X.客户=Y.客户 order by 日期 desc)

解决方案 »

  1.   

    select * from 表 a where exists (select 1 from (select 客户,max(日期) 日期 from 表 group by 客户) b where a.客户=b.客户 and a.日期=b.日期)
      

  2.   

    select 客户,max(日期) from 客户资金表 group by  客户;
      

  3.   

    create table lt 
    (a  char(4), b datetime)
    select * from lt
    --insert lt values('F004','2002-01-05')
    select * from lt a 
        where exists (select 1 from 
                             (select a,max(b) b from lt group by a) b 
                                    where a.a = b.a and a.b=b.b)
      

  4.   

    select 客户,max(日期) as rq into #t from 客户资金表 group by  客户
    select 客户,日期 ,资金 from 客户资金表 k 
                   inner join #t t on k.客户=t.客户 and k.日期=t.rq
      

  5.   

    select * from table1 where (客户   ,  日期  )
    in (select 客户   , max( 日期 ) from table1 group by 客户 ,日期                  )
      

  6.   

    select * from table1 where 
      日期  =(select max(a.日期) from table1 a where a.客户=table1.客户)
      

  7.   

    select * from 客户资金表 as a 
    where a.日期 in(select max(日期) from 客户资金表 where a.客户=客户    group by 客户)
      

  8.   

    select * 
    from T a
    where 日期  =(select max(日期) 
                    from T
                   where 客户=a.客户)
      

  9.   

    select d.*  from #tt d,
       ( select 客户 ,max( 日期 )   日期  from #tt  group by 商品名 ) c
    where d.客户 =c.客户  and d. 日期 =c. 日期
      

  10.   


    select a.*,b.资金 from (select 客户,max(日期) ord from test group by 客户) a,
    test b where b.客户=a.客户 and b.日期=a.日期
      

  11.   

    又弄错了一个地方。
    select a.*,b.资金 from (select 客户,max(日期) 日期 from test group by 客户) a,
    test b where b.客户=a.客户 and b.日期=a.日期