Make this query work in PostgreSQL.