Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SQL – 10 Recent placed orders

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

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;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading