user6537067
user6537067

Reputation: 397

MYSQL Query select only records with latest status as Positive

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:

Sample

Upvotes: 1

Views: 187

Answers (2)

NIKHIL NEDIYODATH
NIKHIL NEDIYODATH

Reputation: 2932

SELECT * FROM YourTable WHERE Status='Active';

Upvotes: 0

Gordon Linoff
Gordon Linoff

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

Related Questions