SELECT region, person, sum(dollars) as thousands
FROM sales
GROUP BY region, person
ORDER BY region, sum(dollars) desc
上面的 SQL 生成每个区域的销售人员的完整列表,如下所示
region person thousands
canada mike smith $114
canada joe blog $76
canada pete dodd $45
usa john doe $253
usa jane smyth $120
europe pieter tsu $546
europ mike lee $520
如果我只想展示每个地区的顶级销售人员(如下所示),我怎样才能最好地做到这一点?
region person thousands
canada mike smith $114
usa john doe $253
europe pieter tsu $546