SQL | Compare single column value with range of other values in SQL | ALL and ANY Operators

preview_player
Показать описание
In this video we see how to compare a single column value with a range of other values in SQL using the ALL and ANY operators.

The ANY and ALL operators allow you to perform a comparison between a single column value and a range of other values.

The ANY operator:

*Returns a Boolean value as a result
*Returns TRUE if ANY of the subquery values meet the condition

ANY means that the condition will be true if the operation is true for any of the values in the range.

The ALL operator:

*Returns a Boolean value as a result
*Returns TRUE if ALL of the subquery values meet the condition
*Is used with SELECT, WHERE and HAVING statements

ALL means that the condition will be true only if the operation is true for all values in the range.

Tables used :

/*
CREATE TABLE student_all_any(
stud_name varchar(255),
stud_age int
);

*/

/*
insert into student_all_any(stud_name, stud_age)
values('raja',28),('papan',20),('chackochi',19),('tom',37),('jerry',45),
('scoobee',55),('oogy',32),('vava',24),
('sidhan',21),('lulu',27),('fernando',65);
*/

/*
CREATE TABLE lecturer_all_any(
lect_name varchar(255),
lect_age int
);
*/

/*
INSERT INTO lecturer_all_any(lect_name, lect_age)
values('hamil',35),('russel',51),('versta',49),('noris',48),('ocon',61),
('gasly',39),('tsuno',51),('vettel',33),
('alonso',31),('bottas',41);
*/

#data_project_hub
#dataprojecthub
#dataanalytics
#sqlqueries
#sqlinterviewquestions
Рекомендации по теме
welcome to shbcf.ru