On 2023-Jan-12, Ron wrote: > Postgresql 12.11 > > This might be more of a bash question, or it might be a psql vs engine problem. > > I want to run this query using psql from a bash prompt: > select format('SELECT ''%s'', MIN(part_date) FROM %s;', table_name, table_name) > from dba.table_structure > order by table_name\gexec Yeah, what I use in these cases is something like echo "select format('SELECT ''%s'', MIN(part_date) FROM %s;', table_name, table_name) from dba.table_structure order by table_name \gexec" | psql -f- -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "El hombre nunca sabe de lo que es capaz hasta que lo intenta" (C. Dickens)