Comments on: Anti-Search patterns – SQL to look for what is NOT there – Part One https://technology.amis.nl/2010/12/20/anti-search-patterns-sql-to-look-for-what-is-not-there-part-one/ Friends of Oracle and Java Sat, 01 Aug 2015 11:10:05 +0000 hourly 1 http://wordpress.org/?v=4.2.3 By: Lucas Jellema https://technology.amis.nl/2010/12/20/anti-search-patterns-sql-to-look-for-what-is-not-there-part-one/#comment-6421 Wed, 22 Dec 2010 06:42:32 +0000 http://technology.amis.nl/blog/?p=9437#comment-6421 Hi Laurent,

 

Dirty trick or not – I like it!

thanks for the contribution to the collection.

Lucas

]]>
By: Laurent Schneider https://technology.amis.nl/2010/12/20/anti-search-patterns-sql-to-look-for-what-is-not-there-part-one/#comment-6420 Mon, 20 Dec 2010 19:09:42 +0000 http://technology.amis.nl/blog/?p=9437#comment-6420 @Anton: did you try your query :-))
@lucas : without subquery, without join, with some dirty trick

create or replace type tn as table of number(4)
/

SELECT DISTINCT
CASE
WHEN empno NOT MEMBER OF
CAST (
COLLECT (DISTINCT mgr) OVER () AS tn
)
THEN ename
END ename
FROM emp
ORDER BY 1;

ENAME
———-
ADAMS
ALLEN
JAMES
MARTIN
MILLER
SMITH
TURNER
WARD

]]>
By: Timo Raitalaakso https://technology.amis.nl/2010/12/20/anti-search-patterns-sql-to-look-for-what-is-not-there-part-one/#comment-6419 Mon, 20 Dec 2010 13:24:16 +0000 http://technology.amis.nl/blog/?p=9437#comment-6419 Do you actually get desired results with not in? s.mgr may be null.

]]>
By: Anti-Search patterns – SQL to look for what is NOT there – Part … « Cache https://technology.amis.nl/2010/12/20/anti-search-patterns-sql-to-look-for-what-is-not-there-part-one/#comment-6418 Mon, 20 Dec 2010 12:02:42 +0000 http://technology.amis.nl/blog/?p=9437#comment-6418 […] Read more from the original source: Anti-Search patterns – SQL to look for what is NOT there – Part … […]

]]>
By: Anton Scheffer https://technology.amis.nl/2010/12/20/anti-search-patterns-sql-to-look-for-what-is-not-there-part-one/#comment-6417 Mon, 20 Dec 2010 09:19:09 +0000 http://technology.amis.nl/blog/?p=9437#comment-6417 You missed, at least, one more way to find the managers without subordinates:
select ename 
from   emp e 
where  e.empno not in ( select s.mgr
                        from   emp s
                      )

]]>