Hello

I would simply inner join, then filtering.

Best Regards.


On Fri, Feb 21, 2014 at 12:11 PM, David Bicking <dbic...@yahoo.com> wrote:

>
> --------------------------------------------
> On Fri, 2/21/14, Igor Tandetnik <i...@tandetnik.org> wrote:
>
>  Subject: Re: [sqlite] partially excluding records
>  To: sqlite-users@sqlite.org
>  Date: Friday, February 21, 2014, 2:58 PM
>
>  On 2/21/2014 1:23 PM,
>  David Bicking wrote:
>  >> SELECT Key, COUNT(STATUS) Cnt
>  >> , MIN(STATUS) || CASE WHEN COUNT(STATUS)>1 THEN '+' ELSE '' END
> Statuses
>  >> FROM T1
>  >> WHERE ...
>  >> GROUP BY KEY;
>  >>
>
> > You might be looking for something like this:
> > select key, sum(STATUS != 'C') + (case when sum(STATUS != 'C') = 0 then
>  sum(STATUS
> > 'C') else 0 end) Cnt, ...
>
> > No special WHERE clause needed.
>
> *** found another typo in my example, that should have been WHEN
> COUNT(DISTINCT STATUS)>1 ***
>
> *** Annoying that they make up their minds that they want it to work like
> this today, then end the meeting with... and you can have this done by
> Monday, right? I need to calm down. ***
>
> Anyway, there are other fields and messy CASE statements that probably
> wouldn't work with this solution.
>
> But I am curious, wouldn't this yield a "Statuses" for key 2 of 'C+', when
> it should be 'O'?
>
> Thanks,
> David
>
>  _______________________________________________
>  sqlite-users mailing list
>  sqlite-users@sqlite.org
>  http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to