From: Clive Swan <cliveswan@gmail.com>
To: 'SQL Padawan' <sql_padawan@protonmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: RE: Get COUNT results from two different columns
Date: Thu, 23 Sep 2021 16:16:28 +0100
Message-ID: <003e01d7b08d$fbe00980$f3a01c80$@gmail.com> (raw)
In-Reply-To: <P_uiZUR4inQ8pRoFheaMsOm9ho0Eo6F8tO3rSbdLRQo-vexNeohsVfUrk2d0YJFqrEejlH4yt6PfShetrVrpDbDmaOxKnbmZ2JXUdYq2MdQ=@protonmail.com>
References: <002d01d7b080$1d339060$579ab120$@gmail.com>
<P_uiZUR4inQ8pRoFheaMsOm9ho0Eo6F8tO3rSbdLRQo-vexNeohsVfUrk2d0YJFqrEejlH4yt6PfShetrVrpDbDmaOxKnbmZ2JXUdYq2MdQ=@protonmail.com>
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@protonmail.com]
Sent: 23 September 2021 14:50
To: cliveswan@gmail.com
Cc: pgsql-general@lists.postgresql.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: cliveswan@gmail.com, sql_padawan@protonmail.com
Subject: Re: Get COUNT results from two different columns
In-Reply-To: <003e01d7b08d$fbe00980$f3a01c80$@gmail.com>
References: <002d01d7b080$1d339060$579ab120$@gmail.com> <P_uiZUR4inQ8pRoFheaMsOm9ho0Eo6F8tO3rSbdLRQo-vexNeohsVfUrk2d0YJFqrEejlH4yt6PfShetrVrpDbDmaOxKnbmZ2JXUdYq2MdQ=@protonmail.com> <003e01d7b08d$fbe00980$f3a01c80$@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox