From: | "Clive Swan" <cliveswan(at)gmail(dot)com> |
---|---|
To: | "'SQL Padawan'" <sql_padawan(at)protonmail(dot)com> |
Cc: | <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | RE: Get COUNT results from two different columns |
Date: | 2021-09-23 15:16:28 |
Message-ID: | 003e01d7b08d$fbe00980$f3a01c80$@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Greetings,
Thanks for the message.
The error message that I get is.
ERROR:
subquery in FROM must have an alias
Hint: For example, FROM (SELECT ...) [AS] foo.
Position: 100
Trying to make sense of it..
Clive
-----Original Message-----
From: SQL Padawan [mailto:sql_padawan(at)protonmail(dot)com]
Sent: 23 September 2021 14:50
To: cliveswan(at)gmail(dot)com
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: RE: Get COUNT results from two different columns
Hi,
> I have two separate queries that work individually, returning a count from each column.
> I would appreciate any pointers.
> new_sup, COUNT(new_sup) AS new_sup_count
> old_sup, COUNT(old_sup) AS old_sup_count
At least some of your problem is here - in your UNION-ed table, this is one and the same field and therefore cannot have two different names.
HTH,
SQL Padawan
From | Date | Subject | |
---|---|---|---|
Next Message | rihad | 2021-09-23 15:32:59 | Currently running queries with actual arguments? |
Previous Message | Marc Olivé | 2021-09-23 14:20:34 | Re: Get COUNT results from two different columns |