SET Nocount ON
Use tempdb
Go
IF (object_id (' T1 ') is not NULL)
DROP TABLE T1
CREATE TABLE T1 (n INT)
INSERT into T1
SELECT 2
UNION
SELECT 3
IF (object_id (' T2 ') is not NULL)
DROP TABLE T2
CREATE TABLE T2 (n INT)
INSERT into T2
SELECT 1
UNION
SELECT 2
UNION
SELECT 3
UNION
SELECT 4
--T1 table data 2,3
--T2 table Data 1,2,3,4
SELECT *
from T1
SELECT *
From T2
--' >all ' indicates that the data for column n in the T2 table is greater than the number of columns n in the T1 table, and the result is only 4.
SELECT *
From T2
WHERE n > All (SELECT n
from T1)
--4
SELECT *
From T2
WHERE n > any (SELECT n
from T1)
--3,4
SELECT *
From T2
WHERE n > SOME (SELECT n
from T1)
--3,4
SELECT *
From T2
WHERE n = All (SELECT n
from T1)
--No data
SELECT *
From T2
WHERE n = any (SELECT n
from T1)
--2,3
SELECT *
From T2
WHERE n = SOME (SELECT n
from T1)
--2,3
SELECT *
From T2
WHERE N < All (SELECT n
from T1)
--1
SELECT *
From T2
WHERE N < any (SELECT n
from T1)
--1,2
SELECT *
From T2
WHERE N < SOME (SELECT n
from T1)
--1,2
SELECT *
From T2
WHERE n <>all (SELECT n
from T1)
--1,4
SELECT *
From T2
WHERE n <>any (SELECT n
from T1)
--1,2,3,4
SELECT *
From T2
WHERE n <>some (SELECT n
from T1)
--1,2,3,4
SET Nocount OFF