PostgreSQL GROUP BY: SELECT column on MAX of another WHERE a third column = x
问题 Let's suppose we have two tables in PostgreSQL: Table "citizens" country_ref citizen_name entry_date ----------------------------------------------------- 0 peter 2013-01-14 21:00:00.000 1 fernando 2013-01-14 20:00:00.000 0 robert 2013-01-14 19:00:00.000 3 albert 2013-01-14 18:00:00.000 2 esther 2013-01-14 17:00:00.000 1 juan 2013-01-14 16:00:00.000 3 egbert 2013-01-14 15:00:00.000 1 francisco 2013-01-14 14:00:00.000 3 adolph 2013-01-14 13:00:00.000 2 emilie 2013-01-14 12:00:00.000 2 jacques