Reputation: 397
Hi I have a table containing records of status of each member of an organization. I would like to find out who among the members are still active based on the latest status provided in the table.Hee is a sample of records in the table:
Upvotes: 1
Views: 187
Reputation: 1269873
You can get the last status for each name using a subquery in the where
clause:
select t.*
from t
where t.date = (select max(t2.date) from t t2 where t2.name = t.name);
You can use an additional conditional expression to determine who is active.
Upvotes: 3