I have the following assignment: Write SQL statement that retrieves orderID, CustomerName and customerID for the 10 most recently placed orders.
The database has information about orders and customers etc.
The database can be found here and it’s also where I write my my code: https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_top_orderby
I tried:
<code>SELECT TOP 10 Orders.OrderID, Customers.CustomerName, Customers.CustomerID
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID
ORDER BY Orders.OrderDate DESC;
</code>
<code>SELECT TOP 10 Orders.OrderID, Customers.CustomerName, Customers.CustomerID
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID
ORDER BY Orders.OrderDate DESC;
</code>
SELECT TOP 10 Orders.OrderID, Customers.CustomerName, Customers.CustomerID
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID
ORDER BY Orders.OrderDate DESC;
However it shows 11 rows instead of 10. The weird thing is that if I try with another number like 9 its shows 9 rows.
New contributor
NoraJones123 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1