I have this query to check one thing:
SELECT DISTINCT ON (person_id) person_id, persn.name, (CASE WHEN status = \'inactive\' then \'Ex-Customer\'