question

Simran02 avatar image
Simran02 asked

Latest 3 orders

How to fetch latest 3 orders for a customer. Suppose, we only have one table with 3 columns - Name, Price and Year.

Name Price Year
Ram  40    2018
Ram  50    2017
Shaam 70   2021
Ram  30    2021
Shaam 20   2015
Ram  10    2013

Expected output:

Ram 30 40 50

Shaam 70 20


I want to fetch latest three orders for a customer, and if there are less than three orders then fetch accordingly (like Shaam).


Please help. Thanks in advance.

mysql
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.