Exam 2 ISM 641 Flashcards
(49 cards)
Find the largest department
A) select deptno from emp group by deptno having count() is maximum;
B) select deptno from emp group by deptno having count() = (select max(count()) from emp group by
deptno);
C) select deptno from emp group by deptno having count() >= all (select max(count()) from emp group
by deptno);
D) select deptno from emp group by deptno having count() >= all (select count(*) from emp group by
deptno);
D) select deptno from emp group by deptno having count() >= all (select count() from emp group by
deptno);
(check all that apply) Find all managers who has no supervisees
A) select ename from emp where (job, empno) not in (select job, mgr from emp);
B) select ename from emp where job = ‘MANAGER’ and empno not in (select mgr from emp where mgr is not null);
C) (select ename from emp where job = ‘MANAGER’) minus (select ename from emp where empno in (select mgr from emp));
D) (select ename from emp where job = ‘MANAGER’)) intersect (select ename from emp where empno in (select mgr from emp));
B) select ename from emp where job = ‘MANAGER’ and empno not in (select mgr from emp where mgr is not null);
C) (select ename from emp where job = ‘MANAGER’) minus (select ename from emp where empno in (select mgr from emp));
Find the maximum salary in Dallas
A) select max(sal) from emp, dept where dept.deptno = emp.deptno;
B) select max(sal) from emp where deptno in (select deptno from dept where loc=’DALLAS’);
C) select sal from emp, dept where loc=’DALLAS’;
D) select max(sal) from emp where loc = ‘DALLAS’
B) select max(sal) from emp where deptno in (select deptno from dept where loc=’DALLAS’);
(check all that apply) Find all the employees located in Dallas
A) select ename from dept where loc = ‘DALLAS’;
B) select ename from dept, emp where dept.depto = emp.deptno and loc = ‘DALLAS’;
C) select ename from dept, emp where loc = ‘DALLAS’;
D) select ename from emp where loc = ‘DALLAS’;
E) select ename from emp where deptno in (select deptno from dept where loc = ‘DALLAS’);
B) select ename from dept, emp where dept.depto = emp.deptno and loc = ‘DALLAS’;
E) select ename from emp where deptno in (select deptno from dept where loc = ‘DALLAS’);
(check all that apply) Find all salesman who makes more than that all managers make
A) select salesman from emp where sal > all (select max(sal) from emp where job = ‘MANAGER’);
B) select ename from emp where sal > all (select sal from emp where mgr = empno);
C) select ename from emp where job = ‘SALESMAN’ and sal > (select max(sal) from emp where job = ‘MANAGER’);
D) select ename from emp where job = ‘SALESMAN’ and sal > all (select sal from emp where job =
‘MANAGER’);
E) none of the above
C) select ename from emp where job = ‘SALESMAN’ and sal > (select max(sal) from emp where job = ‘MANAGER’);
D) select ename from emp where job = ‘SALESMAN’ and sal > all (select sal from emp where job =
‘MANAGER’);
Find those jobs who have the smallest total salary of all the jobs
A) select job from emp group by job having count(sal) <= all (select count(sal) from emp group by job);
B) select job from emp group by job having sum(sal) <= all (select sum(sal) from emp group by job);
C) select job from emp group by job having sum(sal) = (select min(sum(sal)) from emp group by job);
D) select job from emp where sum(sal) <= all (select sum(sal) from emp group by job);
B) select job from emp group by job having sum(sal) <= all (select sum(sal) from emp group by job);
Based on the tables shown below, find the department that has the smallest average salary.
A) select deptno from emp group by deptno having min(sal) <= all (select avg(sal) from emp group by deptno);
B) select dname from emp group by deptno having avg(sal) <= (select avg(sal) from emp group by
deptno);
C) select deptno from emp group by deptno having avg(sal) = (select min(avg(sal)) from emp group by deptno);
D) select deptno from emp group by deptno having avg(sal) <= all (select avg(sal) from emp group by deptno);
D) select deptno from emp group by deptno having avg(sal) <= all (select avg(sal) from emp group by deptno);
Based on the following table, which is the correct SQL statement to find the employees who work
in the same department as SMITH?
A) select ename from emp where job = (select ename from emp where ename = ‘SMITH’);
B) select ename from emp where deptno = (select deptno from emp where ename = ‘SMITH’);
C) select ename from emp where dname = (select dname from emp where ename = ‘SMITH’);
D) select ename from emp where deptno = (select * from emp where ename = ‘SMITH’);
B) select ename from emp where deptno = (select deptno from emp where ename = ‘SMITH’);
Based on the following table, which is the correct SQL statement to find the employees who was hired in the same year as TURNER?
A) select ename from emp where hiredate = (select hiredate from emp where ename = ‘TURNER’);
B) select ename from emp where hiredate in (select * from emp where ename = ‘TURNER’);
C) select ename from emp where to_char(hiredate,’YYYY’) in (select to_char(hiredate, ‘YYYY’) from emp where ename = ‘TURNER’);
D) select ename from emp where * = (select * from emp where ename = ‘TURNER’);
C) select ename from emp where to_char(hiredate,’YYYY’) in (select to_char(hiredate, ‘YYYY’) from emp where ename = ‘TURNER’);
Find all employees who have a job as salesman.
A) select all salesman from emp;
B) select empno, ename from emp where job = ‘salesman’;
C) select Count() from salesman;
D) select Count() from emp where job = ‘salesman’;
B) select empno, ename from emp where job = ‘salesman’;
Find all managers who make more than 2000 dollars
A) select ename from emp where job = ‘MANAGER’ or sal > 2000;
B) select manager from emp where sal > 2000;
C) select ename from emp where job = ‘MANAGER’ and sal > 2000;
D) select ename from emp where job = MANAGER and sal > 2000;
C) select ename from emp where job = ‘MANAGER’ and sal > 2000;
Find the location for Research Department
A) select loc from dept, emp where dname=’RESEARCH’;
B) select loc from dept where dname = ‘RESEARCH’;
C) select loc from dept where deptno in (select deptno from emp where loc=’DALLAS’);
D) select loc from dept inner join emp on dept.deptno = emp.deptno;
B) select loc from dept where dname = ‘RESEARCH’;
Find employees whose name has a letter S in it
A) select ename from emp where ename like ‘S%’;
B) select ename from emp where ename like ‘S*’;
C) select ename from emp where ename = ‘%S%’;
D) select ename from emp where ename like ‘%S%’;
E) select ename from emp where ename in ‘%S%’;
D) select ename from emp where ename like ‘%S%’;
To add a value to an empty cell of an existing record, you would use
A) Insert statement
B) Select statement
C) Update statement
D) Delete statement
C) Update statement
What can the statement “select constraint_name from user_constraints where table_name = ‘ACCOUNTS’” do?
A) find all the primary keys on Account table
B) find all the foreign keys on Account table
C) find all domain validation rules on Account table
D) All of the above
D) All of the above
Find those employees whose name starts with letter K
A) select * from emp where ename like ‘K’;
B) select * from emp where ename like ‘%K%’;
C) select * from emp where ename like ‘K*’;
D) select * from emp where ename like ‘K%’;
D) select * from emp where ename like ‘K%’;
Find the department located in BOSTON in the following table: DEPT(DEPTNO, DNAME, LOC)
A) select department from DEPT where loc= BOSTON;
B) select deptno from DEPT where location = ‘BOSTON’;
C) select dname from dept where loc=BOSTON;
D) select * from DEPT where loc=’BOSTON’;
D) select * from DEPT where loc=’BOSTON’;
Finds all salesmen who are making less than 1500 dollars
A) select salesman from emp where sal < 1500;
B) select * from emp where sal < 1500;
C) select ename from salesman where sal < 1500;
D) select ename from emp where job = ‘SALESMAN’ and sal < 1500;
D) select ename from emp where job = ‘SALESMAN’ and sal < 1500;
The second referential integrity rule states that
A) each table must have a primary key
B) the data for a foreign key column must exist in the corresponding primary key colmun
C) recursive relationship is always optional to optional
D) columns with frequent changes in value should not be made a primary key
B) the data for a foreign key column must exist in the corresponding primary key colmun
Give 5% salary increase to each employee who makes the smallest salary in his or her department
A) update emp set sal = sal * 1.05 where sal = (select min(sal) from emp group by deptno);
B) update emp b set sal = sal * 1.05 where sal = (select min(a.sal) from emp group by a.deptno having a.deptno = b.deptno);
C) update emp b set sal = sal * 1.05 where sal = (select min(a.sal) from emp a where a.deptno = b.deptno)
D) update emp a set sal = sal * 1.05 where a.deptno = b.deptno;
C) update emp b set sal = sal * 1.05 where sal = (select min(a.sal) from emp a where a.deptno = b.deptno)
For all the employees supervised by KING, give them a salary increase, which is equal to the 2%
of the company’s average salary
Code A:
<pre>
update emp
set sal = Sal +
(select 0.02 * avg(sal) from emp)
where mgr in
(select empno from emp where ename = 'KING');
</pre>
Code B:
<pre>
update emp
set sal =
(select avg(1.02*sal) from emp)
where mgr in
(select empno from emp);
</pre>
Code C:
<pre>
update emp a, emp b
set a.sal =
(select avg(1.02*a.sal) from emp)
where a.mgr in
(select empno from emp b where b.ename = 'KING');
</pre>
A) A, B, and C
B) A and B
C) B and C
D) A and C
E) A only
E) A only
Function decode(comm, null, 0, comm) is the same as
A) NVL(comm, 0)
B) decode(comm, comm, comm, 0)
C) update emp set comm = 0 where comm is null;
D) update comm = 0 when comm is null
A) NVL(comm, 0)
Base on the tables shown in the figure below, give 2% salary increase to those who have the longest employment in their corresponding department.
Code A.
<pre>
update emp a
set a.sal = 1.02 * a.sal
where a.hiredate = (select min(b.hiredate)
from emp b
where b.deptno = a.deptno);
</pre>
Code B:
<pre>
update emp
set sal = 1.02 * sal
where (deptno, hiredate) in (select deptno, min(hiredate)
from emp
group by deptno);
</pre>
Code c:
<pre>
update emp
set sal = 1.02 * sal
where empno in
(select empno from emp a
where a.hiredate = (select min(b.hiredate) from emp b
where b.deptno = a.deptno)));
</pre>
A) A, B, and C
B) A and B
C) B and C
D) A and C
E) C only
A) A, B, and C
Find the top salary earner hired each year.
A) select ename from emp where sal in (select max(sal) from emp group by hiredate);
B) select ename from emp where (hiredate, sal) in (select hiredate, max(sal) from emp group by hiredate);
C) select ename, to_char(hiredate, ‘month’) from emp where (to_char(hiredate, ‘month’), sal) in (select to_char(hiredate, ‘month’), max(sal) from emp group by to_char(hiredate, ‘month’));
D) select ename, to_char(hiredate, ‘YYYY’) from emp where (to_char(hiredate, ‘YYYY’), sal) in (select to_char(hiredate, ‘YYYY’), max(sal) from emp group by to_char(hiredate, ‘YYYY’));
D) select ename, to_char(hiredate, ‘YYYY’) from emp where (to_char(hiredate, ‘YYYY’), sal) in (select to_char(hiredate, ‘YYYY’), max(sal) from emp group by to_char(hiredate, ‘YYYY’));
select sum(sal) from ( (select sal from emp where comm is null) union (select sal from emp where comm is not null) )A) there is no need to use union B) after from must be a table, not a subquery C) the union will remove duplicate salaries D) nothing wrong
db.grantRolesToUser( "scott", [ "readWrite" , { role: "read", db: "reporting" } ] )A) reporting B) the current database the user is in C) myDB D) admin E) not specified