RE: Get COUNT results from two different columns

From: SQL Padawan <sql_padawan(at)protonmail(dot)com>
To: cliveswan(at)gmail(dot)com
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: RE: Get COUNT results from two different columns
Date: 2021-09-23 13:50:20
Message-ID: P_uiZUR4inQ8pRoFheaMsOm9ho0Eo6F8tO3rSbdLRQo-vexNeohsVfUrk2d0YJFqrEejlH4yt6PfShetrVrpDbDmaOxKnbmZ2JXUdYq2MdQ=@protonmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marc Olivé 2021-09-23 14:20:34 Re: Get COUNT results from two different columns
Previous Message Ray O'Donnell 2021-09-23 13:47:12 Re: Get COUNT results from two different columns