Re: Escape parentheses in aggregate function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Escape parentheses in aggregate function
Date: 2019-08-30 15:18:06
Message-ID: 26321.1567178286@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rich Shepard <rshepard(at)appl-ecosys(dot)com> writes:
> 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';

I think your problem is the line break, not the parentheses.
psql knows how to count parens, but it has no concept of letting
backslash commands continue across lines.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2019-08-30 16:20:34 Re: Escape parentheses in aggregate function
Previous Message Rich Shepard 2019-08-30 15:11:28 Escape parentheses in aggregate function