Alright, so I have a table of persons and each person belongs to a couple. I need to run a query that gets only the older member of each couple. Here is my schema:
id BIGINT
name VARCHAR(32)
couple_id VARCHAR(255)
birthdate TIMESTAMP
And the query I'm working on:
SELECT * FROM person
GROUP BY couple_id
HAVING birthdate > ???
The couple_id is a randomized string. Currently the output looks like this:
1 John AAA 1985/12/04
2 Jane AAA 1984/01/02
3 Christopher BBB 1991/07/07
4 Christina BBB 1992/08/20
5 Alex CCC 1995/02/07
6 Alexandra CCC 1996/11/12
I need a query that returns the rows John, Christina, and Alexandra.