m: David G. Johnston [mailto:david.g.johns...@gmail.com]
Sent: 23 September 2021 17:45
To: clives...@gmail.com
Cc: pgsql-generallists.postgresql.org
Subject: Re: Get COUNT results from two different columns
On Thu, Sep 23, 2021 at 6:37 AM Clive Swan wrote:
Greetings,
I have two separate queries th
On Thu, Sep 23, 2021 at 6:37 AM Clive Swan wrote:
> Greetings,
>
> I have two separate queries that work individually, returning a count from
> each column.
>
>
>
> I want to subtract New(COUNT) from Old(Count)
>
>
> I get an error when trying to run UNION?
>
While you finally did provide this
]
Sent: 23 September 2021 14:50
To: clives...@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
Seems to me that's not an UNION, but a JOIN:
SELECT o.old_count - n.new_count, o.old_sup, n.new_sup
FROM (
SELECT new_sup, COUNT(new_sup)
FROM public."Data"
GROUP BY new_sup
) n
JOIN (
SELECT old_sup, COUNT(old_sup)
FROM public."Data"
GROUP BY old_sup
) o ON o.old_su
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,
On 23/09/2021 14:37, Clive Swan wrote:
Greetings,
I have two separate queries that work individually, returning a count
from each column.
I want to subtract New(COUNT) from Old(Count)
I get an error when trying to run UNION?
At a quick guess, you'll need to move the subtraction outside the
Greetings,
I have two separate queries that work individually, returning a count from
each column.
I want to subtract New(COUNT) from Old(Count)
I get an error when trying to run UNION?
I would appreciate any pointers.
-- COUNT NEW SUPPLIER
--
SELECT new_sup,
COUNT(new_sup)
FRO