Answer to Question #182600 in Databases | SQL | Oracle | MS Access for Aditya Surana

Question #182600

Show the most recent five orders that were purchased from account numbers that have spent more than $70,000 with AdventureWorks.


1
Expert's answer
2021-04-17T18:48:35-0400
SELECT ss.AccountNumbeR, OrderDate
FROM Sales.SalesOrderHeader ss
WHERE ss.TotalDue > 70000
AND ss.AccountNumber NOT IN (SELECT TOP 5 ss.AccountNumber
                FROM Sales.SalesOrderDetail so
                JOIN Sales.SalesOrderHeader ss
                ON SO.SalesOrderID = ss.SalesOrderID
                HAVING SUM(so.LineTotal > 70000))
GROUP BY ss.TotalDue, ss.AccountNumber, OrderDate 
ORDER BY OrderDate DESC

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS