I am trying to select the max mileage and the second biggest mileage from a table.
my query so far is:
SELECT oil.empid, oil.mileage, users.name, oil.date, MAX(oil.mileage)
FROM oil, users
WHERE oil.empid = users.empid
GROUP BY oil.empid
ORDER BY oil.mileage
but this selects the first mileage entered and the max.
how do i change this to get the second biggest mileage?
Try this:
IF U need only the second last mileage then use this::
If u need both the max as well as the second last use this::