0

How to fetch latest 3 orders for a customer. Suppose, we only have one table Orders 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).

Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175

0 Answers0