Making a mountain out of a mole hill, but isn't the solution more complex
that that? The description has to be Foo & Bar. But if given the following,
then the simple answer dies.
create table requests (request,task,description);
insert into requests values
('REQ0090887','TASK0236753','Foo'),
('REQ0090887','TASK0234920','Bar'),
('REQ0090887','TASK0234921','Bar'),
('REQ0090887','TASK0237261','Foo'),
('REQ0090887','TASK0237261','Wrench'),
('REQ0086880','TASK0224045','Foo'),
('REQ0086880','TASK0224045','Wrench'),
('REQ0086903','TASK0224555','Bar'),
('REQ0086990','TASK0223977','Bar'),
('REQ0087061','TASK0226748','Foo'),
('REQ0087061','TASK0223810','Bar');
with exclude_requests as (
select distinct request from requests where description not in ('Foo','Bar')
)
select request from requests
where request not in (select request from exclude_requests)
group by request
having count(distinct description) = 2
order by request
Doesn't one need to exclude the outliers first?
Have a good one
On Thu, Dec 13, 2018 at 1:44 PM Joseph L. Casale <[email protected]>
wrote:
> -----Original Message-----
> From: sqlite-users <[email protected]> On
> Behalf
> Of Igor Tandetnik
> Sent: Thursday, December 13, 2018 12:16 PM
> To: [email protected]
> Subject: Re: [sqlite] Grouping guidance
>
> > select Request from MyTable group by Request having count(distinct
> > Description) = 2
>
> Nice, I managed it with a join but this is far simpler.
>
> Thanks!
> jlc
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users