SQL : subinterogări

Lucrăm cu Microsoft SQL Server 2014 Enterprise (thanks, MSDNAA).

Subinterogări.

USE [TSQLFundamentals2008];

-- subinterogare si ALL
SELECT orderid AS [Numarul comenzii],
val AS [Valoarea comenzii]
FROM Sales.OrderValues
WHERE val > ALL (SELECT val FROM Sales.OrderValues WHERE val < 1000.00);
GO

-- subinterogare si NOT IN
SELECT orderid AS [Numarul comenzii],
val AS [Valoarea comenzii]
FROM Sales.OrderValues
WHERE val NOT IN (SELECT val FROM Sales.OrderValues WHERE val < 1000.00);
GO