I have a sqlite database named heroes where I am trying to find the second oldest date for each person that has used the service. To find the oldest date I simply used:
SELECT MIN(Date), Cust_Num FROM heroes GROUP BY Cust_Num;
Now, I am using the following to find the second oldest date:
SELECT MAX(Date), Cust_Num FROM heroes WHERE Date IN (SELECT Date FROM heroes ORDER BY Date LIMIT 2) GROUP BY Cust_Num;
However, it is only giving me the 9 people who used the service for a 2nd time on the first day there is data. Any advice?
Thanks!