How come I get no rows selected for this query?
6-1 Write a query to display the employeee name and hire date for all employees in the same department as Blake. Exclude Blake.
select ename, hiredate
from emp
Where job =
(select job
from emp
where ename In ('Blake'));
6-2 Create a query to display the employee number and name for all employees who earn more than the average salary. Sort the results in descending order of salary.
Select empno, ename
from emp
where sal >
(select avg(sal)
from emp);
6-3 Write a query that will display the employee number and name for all employees who work in a department with any employee whose name contains a T. Save your SQL statement in a file.
select empno, ename
from emp
where ename Like '%T%';
6-4 Display the employee name, department number and job title for all employees whose department location is Dallas.
select ename, deptno, job
from emp
where dept.deptno=emp.deptno
and dept.loc =
(select loc
from dept
where loc = 'Dallas');
6-5 Display the employee name and salary of all employees who report to King.
select ename, sal
from emp
where MGr =
(select mgr
from emp
where MGR In ('King'));
6-6 Display the employee name and salary of all employees who report to King.
select deptno, ename, job
from emp
where job =
(select job
from emp
where job In('Sales Department'));
6-1 Write a query to display the employeee name and hire date for all employees in the same department as Blake. Exclude Blake.
select ename, hiredate
from emp
Where job =
(select job
from emp
where ename In ('Blake'));
6-2 Create a query to display the employee number and name for all employees who earn more than the average salary. Sort the results in descending order of salary.
Select empno, ename
from emp
where sal >
(select avg(sal)
from emp);
6-3 Write a query that will display the employee number and name for all employees who work in a department with any employee whose name contains a T. Save your SQL statement in a file.
select empno, ename
from emp
where ename Like '%T%';
6-4 Display the employee name, department number and job title for all employees whose department location is Dallas.
select ename, deptno, job
from emp
where dept.deptno=emp.deptno
and dept.loc =
(select loc
from dept
where loc = 'Dallas');
6-5 Display the employee name and salary of all employees who report to King.
select ename, sal
from emp
where MGr =
(select mgr
from emp
where MGR In ('King'));
6-6 Display the employee name and salary of all employees who report to King.
select deptno, ename, job
from emp
where job =
(select job
from emp
where job In('Sales Department'));