Re: Counting booleans in GROUP BY sections - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Counting booleans in GROUP BY sections
Date
Msg-id 082dc4bf-e668-f091-9d96-9725dd5ddfee@aklaver.com
Whole thread Raw
In response to Re: Counting booleans in GROUP BY sections  (Alexander Farber <alexander.farber@gmail.com>)
Responses Re: Counting booleans in GROUP BY sections  (Alexander Farber <alexander.farber@gmail.com>)
List pgsql-general
On 11/29/19 11:47 AM, Alexander Farber wrote:
> Thank you Adrian, but -

> 
> if I remove GROUP BY mid, then I get the error:
> 
> ERROR:  42803: column "words_moves.mid" must appear in the GROUP BY 
> clause or be used in an aggregate function
> LINE 18:         mid,
>                   ^
> LOCATION:  check_ungrouped_columns_walker, parse_agg.c:1369

Yes because it is a case of opposing forces. When you remove mid from 
the GROUP BY you get an single row for each group that has an aggregated 
output where you can have count of > 1. In that case the database has 
more then one choice for the mid to display and so it throws the error.

To go forward it would help to know what it is you are trying to achieve?

> 
> Regards
> Alex


-- 
Adrian Klaver
adrian.klaver@aklaver.com



pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Counting booleans in GROUP BY sections
Next
From: Michael Paquier
Date:
Subject: Re: pg_basebackup + incremental base backups