Tuesday, 22 May 2012

EXCEPT OR NOT EXIST IN ORACLE / SQL SERVER

Query :

SELECT

[Id],[Title],[Director],[boxOfficeTotal]
FROM [TestApp].[dbo].[MovieDT1]
where boxOfficeTotal > 3000
Except
SELECT ,[Title],[Director],[boxOfficeTotal]

FROM [TestApp].[dbo].[MovieDT1]
where boxOfficeTotal > 4000


Here Output of ths query like

Value between More than 3000 but less than 4000

1)  Except or Not Exist  replaces  use of NOT IN(...)
Instead of using NOT IN in statment query , you can use EXCEPT or NOT EXIST

 2) For better performance ,it works more better than left join or NOT IN

No comments:

Post a Comment