如何在SQL Access数据库表中找到第11个条目?
发布时间:2021-01-19 01:51:30 所属栏目:MsSql教程 来源:网络整理
导读:如何在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=
如何在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 (编辑:威海站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |