Currently I do this in a bash script:
Tbl=table_1
Fld=field_1
Sql="SELECT CURRENT_TIMESTAMP - MIN($Fld) AS days_ago
, MIN($Fld) as oldest_date
, COUNT(*) AS cnt
FROM $Tbl;"
psql -h <host> <db> -Xc "${Sql}"
days_ago | oldest_date | cnt
----------+-------------+-----
| | 0
(1 row)
More stuff happens after this. I want to print out these four lines, but
also test the COUNT(*) value and bypass other bash commands if the count ==
0.
Is there any relatively simple way to do this (psql print and return
count(*))?
--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!