SQL Server Exists Not Exists dont work with min max Aggregate functions

In my last post, I mentioned how @@ROWCOUNT gets affected when MIN, MAX i.e. aggregate functions are used.

Today, I had similar issues while using EXISTS and NOT EXISTS. I was using NOT EXISTS and records were showing up when really it should have removed the results.

select col1 from tbl1 where not exists (select min(something) from tbl2 where tbl2.col9 = tbl1.col2)

select col1 from tbl1 where not exists (select distinct something from tbl2 where tbl2.col9 = tbl1.col2)

Hope this helps.

Comments

Popular posts from this blog

Making text bold in Adobe Acrobat

Translators not loaded --- Translators error in Dreamweaver for coldfusion.htm

Hawks v/s PowerBuilders. July 23 2009. Match 13.