select max(buy_times),customer_id,position_id from exchange_info where customer_id='000000000008' group by customer_id,position_id可以查询出两条记录,我需要查询出这两条记录的所有字段,该怎么写查询语句?
调试欢乐多
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)
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