Give a first try at figuring thse out without running them and then go ahead and run them to see the results.
Problem #1: Does this statement make sense and why? You should use a
subquery if you do not want to show data from the table referenced by
the subquery. If you want to show the data than the join or where link
would be used.
Problem #2: Create a script to create atable called dept or deptcopy etc. and populate the table. The table should
have three fields: deptno which is a 2 digit number, dname which is 14 characters and loc which is 13 characters. The data to go in to the table
is: 10 Accounting, New York, 20 Research Dallas, 30 Sales Chicago and I
added a fourth which was 40 Operations Boston. Show me the script and
the table it created.
Problem #3: Explain and tell the results:
select empno, ename, sal, deptno
from emp
where sal < all
(select sal
from emp
where deptno = 30);
Problem #4: Explain and tell the results:
select deptno, min(sal) + 1000
from emp
group by deptno
having min(sal) + 1000 >
(select avg(sal)
from emp
where deptno = 30);
Problem #5: Explain and tell the results:
select empno, mgr, deptno
from emp
where (mgr, deptno) in
(select mgr, deptno
from emp
where empno in (7900, 7902, 7934));
Problem #6: Explain and tell the results:
select empno, deptno,
(select dname from dept where emp.deptno = dept.deptno)
from emp;
Problem #7: Explain and tell the results:
select deptno, dname
from dept
where exists
(select empno
from emp
where emp.deptno = dept.deptno);