如何在Access sql数据库表中找到第11个条目?我必须使用TOP函数,我的查询目前看起来像这样:
SELECT TOP 11 Passenger.Name,SUM(Manifest.Ticketprice) AS [Total Amount Spent on Tickets] FROM Passenger INNER JOIN Manifest ON Passenger.PassengerNumber=Manifest.PassengerNumber GROUP BY Passenger.Name ORDER BY SUM(Manifest.Ticketprice) DESC;
解决方法
您可以使用子查询:
SELECT TOP 1 T.Name,T.[Total Amount Spent on Tickets] FROM (SELECT TOP 11 Passenger.Name,SUM(Manifest.Ticketprice) AS [Total Amount Spent on Tickets] FROM Passenger INNER JOIN Manifest ON Passenger.PassengerNumber=Manifest.PassengerNumber GROUP BY Passenger.Name ORDER BY SUM(Manifest.Ticketprice) DESC) As T ORDER BY T.[Total Amount Spent on Tickets] ASC