I want to query a database which will select the schema_name,max(date_column),table_name from database in PostgreSQL.
is there any process from which we can achieve the above scenario?
Thanks.
I want to query a database which will select the schema_name,max(date_column),table_name from database in PostgreSQL.
is there any process from which we can achieve the above scenario?
Thanks.
In Postgres you can use a variation of the "row count for all tables" approach:
select table_schema, table_name,
(xpath( '/row/max/text()',
query_to_xml(format('select max(%I) from %I.%I', column_name, table_schema, table_name), true, true, '')
)
)[1]::text::int as max_value
from information_schema.columns
where table_schema = 'public' --<< adjust for your schema name(s)
and column_name = 'date_column' --<< adjust for the real name of your column