Re: Counting booleans in GROUP BY sections

Adrian Klaver <[email protected]>
Newsgroups gmane.comp.db.postgresql.general
Message-ID <[email protected]>
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
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.