Assume there are 3 rows in a PostgreSQL table named tracker
. I want to fetch the latest updated record alone. Please help me achieving it.
(issue_id,priority,ingest_date)
(1,1,"2015-01-27 00:00:00")
(1,2,"2015-01-28 00:00:00")
(1,3,"2015-01-29 00:00:00")
I tried giving
select *
from tracker
where ingest_date = (select max(ingest_date) from tracker);
This works fine for me. But is there any better way I can query the DB?
Thanks in advance.
I want something like
select *
from etl_change_fact
where ingest_date = max(ingest_date);
But I get this error
**ERROR: aggregates not allowed in WHERE clause
**