0

For example I would like to get only the top 10 customer by seller. So it will look like this (without the top 10):

Select seller, customer, sells from table order by seller asc, sells desc

But this will give me all the values. I would only like to have the first 10 customers for each seller.

Is this even possible in ms-access 2003? If yes, please give me a hint, thanks ;)

4

1 回答 1

2

在以下行:

SELECT seller,
       customer,
       sells
FROM   table a
WHERE  customerid IN (SELECT TOP 10 customerid
                      FROM   table b
                      WHERE  b.sellerid = a.sellerid
                      ORDER  BY sells DESC)
ORDER  BY seller ASC,
          sells DESC 

请注意,MS Access 会返回匹配项,因此您可能会获得 10 次以上的返回。如果需要精确的 10 个,您可以通过唯一 ID 订购和销售。

于 2012-10-31T12:05:58.273 回答