你的表结构是什么样的
如果有自增长id,用户userid
那么这样了
select top 1 * from table_name where userid=@userid order by id desc

解决方案 »

  1.   

    select * from tablename where 发生日期=(select max(发生日期) from tablename where 操作工号=@操作工号)
      

  2.   

    select 操作工号,用户名,max(发生日期) from your_table group by 操作工号,用户名
      

  3.   

    select * from tablename a where 发生日期=(select max(发生日期) from tablename b where a.操作工号=b.操作工号)
      

  4.   

    To老兄psxfghost(哈哈) :
    你的语句不行,会有重复的值
      

  5.   

    select a.* from table a,
        (select 用户名,操作工号,max(发生日期) 发生日期 from table group by 用户名,操作工号) b
    where a.用户名=b.用户名 and a.操作工号=b.操作工号 and a.发生日期=b.发生日期
      

  6.   

    select * from yourtable A where 发生日期=(select top 1 发生日期 from yourtable
    B where A.操作工号=B.操作工号 order by 发生日期 desc)
      

  7.   

    我的表结构:发生日期,用户名,消费额,操作工号
    我想取得某操作工号所操作的用户名最近消费额的结果Select A.* from Table A 
    inner join
    (Select 操作工号,用户名,Max(发生日期) 
        From Table 
        Group By 操作工号,用户名) B
    on A.操作工号 = B.操作工号 and a.用户名 = b.用户名