CREATE TABLE users (
id int primary key auto_increment,
name varchar(64),
status enum('single', 'married', 'divorced')
);
INSERT INTO users (name, status) VALUES
('Peter', 'single'),
('Basil', 'single'),
('Peter', 'married'),
('Basil', 'married'),
('Basil', 'divorced');
SELECT * FROM (
SELECT
name,
status,
ROW_NUMBER() OVER (PARTITION BY name ORDER BY id DESC) rn
FROM users) user_status
WHERE rn = 1;