Escape parentheses in aggregate function

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Escape parentheses in aggregate function
Date: 2019-08-30 15:11:28
Message-ID: alpine.LNX.2.20.1908300805200.22705@salmo.appl-ecosys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I want to copy query results to a text file and there's an aggregate
function in the SELECT expression. One of the aggregate function's
parentheses seems to end the \copy() function and I don't know how best to
write the statement. A minimal example:

\copy(select count_value, sum(count_value)
from table_name) to 'output_file.txt';

Do I write sumE'('count_valueE')', sum\(count_value\), or something else?

TIA,

Rich

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2019-08-30 15:18:06 Re: Escape parentheses in aggregate function
Previous Message Niels Jespersen 2019-08-30 15:06:22 Re: SSPI auth and mixed case usernames