Keywords ALL/SOME/ANY

Compares a scalar value with a single-column set of values. SOME and ANY are equivalent.

Here is the example:

CREATE TABLE T1
(ID int) ;
GO
INSERT T1 VALUES (1) ;
INSERT T1 VALUES (2) ;
INSERT T1 VALUES (3) ;
INSERT T1 VALUES (4) ;

it will return "TRUE", because 3 less than some vaules in table.

IF 3 < SOME (SELECT ID FROM T1)
PRINT 'TRUE' 
ELSE
PRINT 'FALSE' ;

it will return "FALSE", because 3 no less than all vaules in table.

IF 3 < ALL (SELECT ID FROM T1)
PRINT 'TRUE' 
ELSE
PRINT 'FALSE' ;

猜你喜欢

转载自www.cnblogs.com/ziqiumeng/p/10171989.html