select   max(buy_times),customer_id,position_id   from   exchange_info   where   customer_id='000000000008'   group   by   customer_id,position_id可以查询出两条记录,我需要查询出这两条记录的所有字段,该怎么写查询语句?

解决方案 »

  1.   

    就没有看懂,不知道这个语句可满足
    select * from  exchange_info where (buy_times,customer_id,position_id ) in (select       max(buy_times) as buy_times ,customer_id,position_id       from       exchange_info       where       customer_id='000000000008'       group       by       customer_id,position_id)
      

  2.   

    select *
      from (select a.*,row_number() over(partition by customer_id,position_id order by buy_times desc) nb
              from exchange_info a)
     where nb = 1
      

  3.   

    就是要查询出来所有得字段,你应该理解了,要不然不会写这条语句给我,不过你这个语句是错的,where后面只能有一个字段行,多个是不行的
      

  4.   

    我的数据库是access的,谢谢大家了