In PostgreSQL, I'm attempting to select the columns in the first select list which have the most recent ff.sub\_date. The unique value in the ff table is object\_id which is what I need to be joining on. My attempt is below:

```
SELECT r0.ein, "TtlRvAndExpnssAmt" AS "Revenue", "TtlAsstsEOYFMVAmt" AS "Assets",
       "CmpOfcrDrTrstRvAndExpnssAmt" AS "Compensation & Benefits Expense" 
FROM filing_filing ff
JOIN return_pf_part_0 r0 ON ff.object_id = r0.object_id
JOIN return_pf_part_i r1 ON ff.object_id = r1.object_id
JOIN return_pf_part_ii r2 ON ff.object_id = r2.object_id
WHERE (ff.ein, sub_date) IN (SELECT ff.ein, max(sub_date)
                             FROM filing_filing ff
                             GROUP BY ff.ein)
  AND ff.ein = '456829368';

```

It seems like what I really need in the subquery is to include the column object\_id, but I can't do that because I can't group by it.

Note: Later on, the WHERE clause will include a long list of ff.EINs