Understanding ALL ANY or SOME in SQL || Lesson 89 || DBMS || Learning Monkey ||
Вставка
- Опубліковано 2 лют 2020
- Here we will try to discuss Understanding ALL, ANY or SOME in SQL.
Understanding ALL ANY or SOME in SQL
Definitions of ALL, ANY or SOME: ALL, ANY or SOME are keywords. These keywords are used with WHERE or HAVING Clause.
ALL, ANY or SOME operates on the subqueries that return multiple values. ALL returns true if all subquery values meet the condition. ANY or SOME returns true if any of the subquery values meet the condition.
To understand this let's consider the employee table of the company database
Understanding ALL Keyword:
Now consider the query with the use of ALL " SELECT fname FROM employee WHERE salary ALL (20000, 25000, 30000); ".
What do the above query states?
The query is going to find the fname of all the employees whose salary is greater than ALL these values 20000, 25000, and 30000.
How this query works is it takes the salary value in each and every row and is compared with all the values given (20000, 25000, 30000).
If the salary in the row is greater than ALL the values then the fnames will be displayed.
Understanding ANY or SOME Keyword:
Consider the same query used with ANY " SELECT fname FROM employee WHERE salary ANY (20000, 25000, 30000); ".
What do the above query states?
The query is going to find the fname of all the employees whose salary is greater than ANY of these values 20000, 25000, and 30000.
How this query works is it takes the salary value in each and every row and is compared with all the values given (20000, 25000, 30000).
If the salary in the row is greater than ANY the values then the fnames will be displayed.
In place of we can use SOME also.
Example Query on ALL, ANY or SOME:
Find the fnames and lnames of all the employees whose salary is greater than all the employees in department number 5.
In order to execute this query, we have to find the salaries of all the employees in department number 5. Then those values are to be compared with every employee salary.
The answer to the query is " SELECT fname, lname FROM employee WHERE salary ALL (SELECT salary FROM employee WHERE dno = 5); ".
The output of the inner query is the salaries of the employees who are working in department number 5 (30000, 40000, 38000, 25000).
Now every employee's salary is compared with ALL the employee's salary of the department number 5.
If the value of the salary is true for all the values then those fname and lname are considered.
Link for our website: learningmonkey.in
Follow us on Facebook @ / learningmonkey
Follow us on Instagram @ / learningmonkey1
Follow us on Twitter @ / _learningmonkey
Mail us @ learningmonkey01@gmail.com
best video, searched everywhere for understanding the concept of all and any but no-one was better than you. Understood 100%
Thanks for your wonderful words. It's good to hear that.
Have a great learning.
Just perfect!!! Exactly what I have been looking for. Thanks a lot
Very good explanation! Thank you !
Great video, loved your series ! Thanks for sharing !!!
God bless you, you are a life saviour. Good and clear explication.
You are a good teacher sir.
Continue teaching 👌
Great example and Lecture :) Thank you so much!
Great work, thank you !
Nice explanation. Searched many training materials to understand ALL and ANY Operators concept, but found this video to have exactly the right amount of information to understand the concept. Great work.
Thank you have a great learning in CSE
Beautiful explanation, thanks for the help mate.
Nice video you have saved my time in understanding this concept
Dear Sir, You are the best teacher I have ever met. Thank you so much for solving a problem that has been a big problem for me. love from Sri Lanka
Welcome good to hear that
Thank you very much.
Tomorrow I have a class presentation on these particular topics
Thanks a lot..... U cleared all of my doubts.... Thank u
Thanks for your feedback.
Thanks you, I have searched and watched more videos but this one is completely different and I understand 100% thakns u for ur good expalination and simple example elaboration thakns yu
Welcome good to hear that
@@LearningMonkey is there any courses you buy like anad javafX
Great sir ..you cleared my doubt🔥🔥
Have a great learning
explanation at 8:58 explains this really well! the three ANDs!
Very good explanation.
well explained !
Great work man!!!
Thank you
really nice explaination bro
it is a good video. Thanks!
Thanks for the informative video
Woooaahhh....best video ❤
Have a great learning in CSE
Nice video...
AWESOME!!
Thanks for your hard work
Hi Vins Patel,
Thanks for your feedback.
Good 👍
Don't keep your channel name anywhere in the below, possible please keep upside anywhere,
awsm
Helpfull
Thank you!
great work
Thank You
Exellent explanation
Thank u anna
Hi Sir, very well explained :) Thank you very much! although i have a (silly) question - if ANY and SOME behave in identical manner, why bother having an extra operator called 'SOME'? should be just ALL or ANY. Hope that makes sense :)
Sir, thank You soo much!
Have a great learning in CSE
Sir what will be the output if we apply >= All operator instead of only >All ?
It will take all those values which would be greater
Very nice video apreciateable
Thank you
thanks
Nice explanation
Thank you
3:08 Kya sahi time pr facebook wala ad dala hai :)
Good One !!
Hi,
SELECT fname, lastname
FROM [dbo].[EMPLOYEE] AS E
WHERE E.SALARY = ALL (SELECT EM.SALARY FROM EMPLOYEE AS EM WHERE EM.DNAME =5 )
why this returns no data.?
Thank you sir
Welcome, thanks for the feedback.
Thank you so much sir ❤️🥺
Most welcome 😊
Thank you
What's the use if you put your channel logo right over where the important point is!?
good job sir
Thankyou
It was written that in dept no. 5 so the values of dept no. 5 would also return
Pls answer
tnx💕💕💕💕
😘🥰
This was looking great until the facebook advertisement banner covered the query, making it impossible to follow. So a really good video until about the 3:05 mark, then essentially useless.
Super
Thank You
Okay, But James and Jennifer do not belong to Dno 5. Could you pls clarify the doubt?
The outer query check the entire table.
Hi , I have a doubt james and jeniffer not belongs to dno 5
wtf not bad
not helpful, your facebook ad blocked the query, absurd
Thank you