এই Lesson এ কক কশখব ?
• Subquery in DBMS (Part-1)
SQL Subqueries (Example)
Write a query to display highest salary department wise and name of the employee who is taking that salary.
Emp_id Emp_name Dept Salary
1 Rajib HR 10000
2 Zahid Marketing 20000
3 Hasan HR 30000
4 Shanta Marketing 40000
5 Zuhana IT 50000
EMP
SQL Subqueries (Example)
Write a query to display highest salary department wise and name of the
employee who is taking that salary.
Emp_id Emp_name Dept Salary
1 Rajib HR 10000
2 Zahid Marketing 20000
3 Hasan HR 30000
4 Shanta Marketing 40000
5 Zuhana IT 50000
EMP
HR 30000
Marketing 40000
IT 50000
select max(salary) from EMP group by dept
SQL Subqueries (Example)
Write a query to display the employee names who is working in a department where No. of employees are less than 2.
Emp_id Emp_name Dept Salary
1 Rajib HR 10000
2 Zahid Marketing 20000
3 Hasan HR 30000
4 Shanta Marketing 40000
5 Zuhana IT 50000
EMP
(select max(salary) from EMP group by dept) select Emp_name from EMP where salary in
False 30000
40000 50000
Inner Query
in
Salary 10000
SQL Subqueries (Example)
Write a query to display the employee names who is working in a department where No. of employees are less than 2.
Emp_id Emp_name Dept Salary
1 Rajib HR 10000
2 Zahid Marketing 20000
3 Hasan HR 30000
4 Shanta Marketing 40000
5 Zuhana IT 50000
EMP
(select max(salary) from EMP group by dept) select Emp_name from EMP where salary in
False 30000
40000 50000
Inner Query
in
Salary 20000
SQL Subqueries (Example)
Write a query to display the employee names who is working in a department where No. of employees are less than 2.
Emp_id Emp_name Dept Salary
1 Rajib HR 10000
2 Zahid Marketing 20000
3 Hasan HR 30000
4 Shanta Marketing 40000
5 Zuhana IT 50000
EMP
(select max(salary) from EMP group by dept) select Emp_name from EMP where salary in
Hasan 30000
40000 50000
Inner Query
in
Salary 30000
SQL Subqueries (Example)
Write a query to display the employee names who is working in a department where No. of employees are less than 2.
Emp_id Emp_name Dept Salary
1 Rajib HR 10000
2 Zahid Marketing 20000
3 Hasan HR 30000
4 Shanta Marketing 40000
5 Zuhana IT 50000
EMP
(select max(salary) from EMP group by dept) select Emp_name from EMP where salary in
Hasan, Shanta 30000
40000 50000
Inner Query
in
Salary 40000
SQL Subqueries (Example)
Write a query to display the employee names who is working in a department where No. of employees are less than 2.
Emp_id Emp_name Dept Salary
1 Rajib HR 10000
2 Zahid Marketing 20000
3 Hasan HR 30000
4 Shanta Marketing 40000
5 Zuhana IT 50000
EMP
(select max(salary) from EMP group by dept) select Emp_name from EMP where salary in
Hasan, Shanta, Zuhana 30000
40000 50000
Inner Query
in
Salary 50000
“Opportunities don’t happen, you create them.”
– – Chris Grosser