This type of scenario is most commonly asked in interviews where we need to find a record in the table whose ranks equals to N. Also, the output can change as per interviewer’s mood, so, we’ll see a few general scenarios where we can plug in the value of ‘N’ and voilà, a simple solution for How to get the Nth Highest record.
Let’s solve, How to get the Nth Highest record?
Let’s dive in, we will be using a table called GROCERY which has different products, expiration status, product’s price, and expiry date.
SELECT * FROM GROCERY;
Assigning ranks to the table Grocery on the basis of product’s rate for our reference.