Re: [sqlite] partially excluding records

2014-02-24 Thread David Bicking
int in full, and I can't even remember what some of the where clauses are meant to do, let alone how I would combine them with new ones. David On Fri, 2/21/14, Igor Tandetnik <i...@tandetnik.org> wrote: Subject: Re: [sqlite] partially excl

Re: [sqlite] partially excluding records

2014-02-21 Thread mm.w
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: > > Subj

Re: [sqlite] partially excluding records

2014-02-21 Thread Igor Tandetnik
On 2/21/2014 3:11 PM, David Bicking wrote: But I am curious, wouldn't this yield a "Statuses" for key 2 of 'C+', when it should be 'O'? You could use the same technique there. The technique lets you know whether you have only C's, only non-C's, or a mix of the two, and act accordingly.

Re: [sqlite] partially excluding records

2014-02-21 Thread David Bicking
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: >> SELEC

Re: [sqlite] partially excluding records

2014-02-21 Thread David Bicking
On Fri, 2/21/14, Clemens Ladisch <clem...@ladisch.de> wrote: Subject: Re: [sqlite] partially excluding records To: sqlite-users@sqlite.org Date: Friday, February 21, 2014, 1:38 PM David Bicking wrote: >> The complication is that if

Re: [sqlite] partially excluding records

2014-02-21 Thread Igor Tandetnik
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; Key Cnt Statuses 1 2 O 2 1 C 4 2 O+ The complication is that if a given key has any

Re: [sqlite] partially excluding records

2014-02-21 Thread David Bicking
On Fri, 2/21/14, RSmith <rsm...@rsweb.co.za> wrote: Subject: Re: [sqlite] partially excluding records To: sqlite-users@sqlite.org Date: Friday, February 21, 2014, 1:34 PM On 2014/02/21 20:23, David Bicking wrote: > I have a t

Re: [sqlite] partially excluding records

2014-02-21 Thread Clemens Ladisch
David Bicking wrote: > The complication is that if a given key has any non-C value, the C values are > to be excluded. First, just exclude all C values: ... WHERE Status <> 'C' ... > If there are only C values, they are to be included. Then do the same query again, but with the all-C keys:

Re: [sqlite] partially excluding records

2014-02-21 Thread RSmith
On 2014/02/21 20:23, David Bicking wrote: I have a table like SELECT * FROM T1; Key Status 1 O 1 O 2 O 2 C 3 C 3 C 4 O 4 P Now, I need to consolidate that data. SELECT Key, COUNT(STATUS) Cnt , MIN(STATUS) || CASE WHEN COUNT(STATUS)>1 THEN '+' ELSE ''