Question
Microsoft SQL Server Management Studio: Show just the customer contact name of the customer with the most orders ( Fig. 2 ). Do not use
Microsoft SQL Server Management Studio:
Show just the customer contact name of the customer with the most orders (Fig. 2). Do not use any hard-coded values or row numbers.
I wrote the SQL Script below and it pulled 89 rows (Fig 1). I need an SQL Code to pull the customer contact name of the customer with the most orders (Fig. 2).
SQL Script:
SELECT T.contactname, (T.OrderCount) AS 'Number Of Orders'
FROM(SELECT contactname, COUNT(O.orderid) AS OrderCount
FROM Sales.Orders O
INNER JOIN Sales.Customers C
ON o.custid = c.custid
GROUP BY contactname) AS T
Fig. 1 contactname Number Of Orders 9 Mallit, Ken 50 Marinova, Nadejda 51 McLin, Nkenge 52 Meston, Tosh 53 Misiec. Anna 54 Moore, Michael 55 Myrcha, Jacek 56 Nagel, Jean-Philippe 57 Navarro, Toms 58 O Brien, Dave 59 Osorio, Cristian 60 Peoples, John 61 Poland, Carole 10 10 13 18 10 6 31 Fig. 2 contactname Number of Orders Navarro, Toms31
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started