On Fri, 12 Oct 2018 08:27:10 +0200
Clemens Ladisch <clem...@ladisch.de> wrote:

> John Found wrote:
> > i.e. how to select only the groups that contain
> > some value in the set of values in a column not
> > specified in group by clause.
> >
> >     select
> >       (select group_concat(b) from t t1 where t1.a = t2.a) as list
> >     from t t2
> >     where b = ?1;
> 
> Similarly:
> 
>   select
>     group_concat(b) as list
>   from t
>   where a in (select a
>               from t
>               where b = ?1)
>   group by a;
> 
> But you will not be able to avoid the subquery: the filter has to
> include all other rows of the group with matching b, and after the
> group_concat(), the result is no longer in a form useful for lookups.
> (And doing the filter after the grouping is probably not efficient.)

Hm, is sounds strange because when HAVING clause is processed, 
the aggregate functions should not be processed yet (for a performance 
reasons) i.e. the query still has access to all values from the field b
and theoretically should be able to search these values the same way
it searches them on executing min() or max() aggregate functions.

> 
> 
> Regards,
> Clemens
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


-- 
John Found <johnfo...@asm32.info>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to