Exam 2 ISM 641 Flashcards
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