Home > Net >  SQL - 10 Recent placed orders
SQL - 10 Recent placed orders

Time:12-15

I struggle a little with the interpretation of this question. (I am a noob in sql). This is the Database I will be using.

I struggle with the interpretation of this question (yet very simple).

question: Write an sql statement that retrieves order number, customer number and customer name for the 10 most recently placed order

select o.orderID,c.customerID,c.customerName
from customers c
join orders o
order by orderdate desc LIMIT 10

Is your interpretation similar? if not, what is your interpretation?

CodePudding user response:

you should join based on condition to have what you want, Try this:

SELECT 
   o.OrderID, c.CustomerID, c.CustomerName 
FROM 
   Orders as o 
join 
   Customers as c on c.CustomerId = o.CustomerID 
order by o.OrderDate desc limit 10;
  • Related