SELECT S.AuctionId, T.userid, T.codename, S.cs
FROM (SELECT AuctionId, COUNT(*) AS cs
FROM BidRecords GROUP BY AuctionId ) S
CROSS APPLY (SELECT TOP 1 userid, codename FROM BidRecords WHERE AuctionId = S.AuctionId) T
------解决方案-------------------- SELECT S.AuctionId, T.userid, T.codename, T.offer, S.cs
FROM (SELECT AuctionId, COUNT(*) AS cs
FROM BidRecords GROUP BY AuctionId ) S
CROSS APPLY (SELECT TOP 1 userid, codename, offer FROM BidRecords WHERE AuctionId = S.AuctionId ORDER BY offer DESC) T ------解决方案--------------------