I have a database table that holds the History of tag reads from RFID Tags.
The main columns are: TAGID, LOCATION and LASTUPDATEDATE.
There are some 20,000+ rows in the table and growing but only 12 unique tags.
The requirement is to show each tag the last 3 locations for the tag and the date it was shown in that location, sorted by TAGID and newest of the 3 dates
This example in the topic may be useful for your issue.
List the top five wage earners.
SELECT EMPNO, LASTNAME, FIRSTNME, TOTAL_SALARY, RANK_SALARY
FROM (SELECT EMPNO, LASTNAME, FIRSTNME, SALARY+BONUS AS TOTAL_SALARY,
RANK() OVER (ORDER BY SALARY+BONUS DESC) AS RANK_SALARY
FROM EMPLOYEE) AS RANKED_EMPLOYEE
WHERE RANK_SALARY < 6
ORDER BY RANK_SALARY