New to SQL Server, and I'm trying to use the top of 1 to get the company with the most orders in my database in my code that already works, but I donβt know how to use it correctly. It seems to me that only the missing syntax is missing.
Request # 1 works fine:
SELECT c.CompanyName, COUNT(DISTINCT OrderID) as Nombre_Commande FROM Orders O INNER JOIN Customers C ON O.CustomerID = c.CustomerID GROUP BY c.CompanyName
What am i trying to do
SELECT TOP (1) * FROM (SELECT c.CompanyName, COUNT(DISTINCT OrderID) AS Nombre_Commande FROM Orders O INNER JOIN Customers C ON O.CustomerID = c.CustomerID GROUP BY c.CompanyName)
sql
Jeffla
source share