Quote: 取出每月通话费最高和最低的两个用户. 1 select bill_month,area_code,sum(local_fare) local_fare, 2 first_value(area_code) 3 over (order by sum(local_fare) desc 4 rows unbounded preceding) firstval, 5 first_value(area_code) 6 over (order by sum(local_fare) asc 7 rows unbounded preceding) lastval 8 from t 9 group by bill_month,area_code 10* order by bill_month SQL> /