I have a paystub table in which the payroll records are recorded.
The fields related to this query are the YearToDateGrossPay and the year.
I need to search through all the paystub records and select the top 5 highest paid years.
The last paystub of each year would tell me the final YTD amounts for that year and then I could select the top 5 of that subquery, but I’m not too sure how to do that.
Any help would be appreciated.
Thanks
If you already have the subquery which selects the final YTD amounts, you can finish it off by
The ORDER BY ytd_amount DESC sorts the table by ytd_amount in descending order
The LIMIT 5 selects the top 5 rows only and chops everything else off