Consider the table employee (empId, name, department, salary) what will be outpu
ID: 3913898 • Letter: C
Question
Consider the table employee(empId, name, department, salary)
what will be output ,, and how ?
please explain complete mechanism in details.
i am can't understand anything how it works.
|| create table employee(empId Int(50), name varchar(50), department int(50), sal 2 insert into employee values (1, 'a', 4, 90) 3 insert into employee values (2, b', 5, 3) 4 insert into employee values (3, 'c, 5, se); 5 insert into employee values (4, 'd', 5, 8e): 6 insert into employee values (8, f', 7, 10) 1 Select 1 Select * From employee e where not exists (Select From employee s where s.department 5 and s.salary e.salary 4Explanation / Answer
The above query meaning:
It refers to find the employees who have get higher or equal salary than all the employees of the department 5.
condition need to satisfy:
since we not exist the following conditions must satisfy.
(Select * From employee s where s.department = 5 and
s.salary > e.salary)
It means select all employee whose department = 5 and s.salary > e.salary
In this situation it consider maximum s.salary that is among 30,50 and 80, 80 is the maximum and 80 compare to remaining salary of e.
80>90 -->false
80>30 -->true
80>50 -->true
80>80 -->false
10>80 -->true
So the tables satisfy the condition
The above output corrospond to
Select *
From employee e
Where exists
(Select * From employee s where s.department = 5 and
s.salary > e.salary)
Here exists means the same data whats the result of where condition
From the question:
Select *
From employee e
Where not exists
(Select * From employee s where s.department = 5 and
s.salary > e.salary)
It is opposite to the exists, it dont give the the data where condition satisfy(It gives all remainig elements of the table which satisy second condition).
Output:
Thank You
Please Rate My answer
2 b 5 30 3 c 5 50 8 f 7 10