Professional Documents
Culture Documents
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Part I of the Semester 2 Mid Term Exam covers Sections 1-4, and the
Review of Joins in Section 5, of Database Programming with SQL
curriculum.
Section 1
1.
You need to return a portion of each employees last name, beginning with
the first character up to the fifth character. Which character function should
you use? Mark for Review
(1) Points
INSTR
TRUNC
SUBSTR (*)
CONCAT
Correct
2.
You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) ID
FROM employee;
In which order are the functions evaluated? Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
You query the database and return the value 95. Which script did you use?
Mark for Review
(1) Points
SELECT SUBSTR(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
(*)
SELECT LENGTH(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
SELECT SUBSTR(product_id, -1, 3)
FROM price
WHERE manufacturer_id = 59604;
SELECT TRIM(product_id, -3, 2)
FROM price
WHERE manufacturer_id = 59604;
Correct
7.
Evaluate this SELECT statement:
SELECT LENGTH(email)
FROM employee;
What will this SELECT statement display? Mark for Review
(1) Points
The longest e-mail address in the EMPLOYEE table
The email address of each employee in the EMPLOYEE table
The number of characters for each value in the EMAIL column in the
employees table (*)
The maximum number of characters allowed in the EMAIL column
Correct
8.
You need to subtract three months from the current date. Which function
should you use? Mark for Review
(1) Points
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Correct
9.
Evaluate this SELECT statement:
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query? Mark for Review
(1) Points
The current date plus 30 hours.
The current date plus 30 days. (*)
The current date plus 30 months.
No value is returned because the SELECT statement generates an error.
Correct
10.
You need to display the current year as a character value (for example:
Two Thousand and One). Which element would you use? Mark for Review
(1) Points
RR
YY
YYYY
YEAR (*)
Correct
Page 1 of 5
Section 1 11. Which SELECT statement will return a numeric value? Mark
for Review
(1) Points
SELECT SYSDATE + 600 / 24
FROM employee;
SELECT ROUND(hire_date, DAY)
FROM employee;
SELECT (SYSDATE hire_date) / 7
FROM employee;
(*)
SELECT SYSDATE 7
FROM employee;
Incorrect. Refer to Section 1
12. Which function would you use to return the current database server
date and time? Mark for Review
(1) Points
DATE
SYSDATE (*)
DATETIME
CURRENTDATE
Correct
13. You issue this SQL statement:
SELECT TRUNC(751.367,-1) FROM dual;
Which value does this statement display?
Mark for Review
(1) Points
700
750 (*)
751
751.3
Correct
14. Which comparison operator retrieves a list of values? Mark for Review
(1) Points
IN (*)
LIKE
BETWEEN IN
IS NULL
Correct
15. You issue this SQL statement:
SELECT ROUND (1282.248, -2) FROM dual;
What value does this statement produce?
Mark for Review
(1) Points
1200
1282
1282.25
1300 (*)
Correct
Section 2 16. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
Evaluate this SELECT statement:
SELECT style_id, style_name, category, cost
FROM styles WHERE style_name LIKE SANDAL AND NVL(cost, 0) <
15.00
ORDER BY category, cost;
Which result will the query provide?
Mark for Review
(1) Points
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
758960 SANDAL 86979
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Correct
25. Which two statements concerning SQL functions are true? (Choose
two.) Mark for Review
(1) Points (Choose all correct answers)
Character functions can accept numeric input.
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data
type. (*)
Single-row functions manipulate groups of rows to return one result per
group of rows.
Correct
Section 3 26. You need to provide a list of the first and last names of all
employees who work in the Sales department who earned a bonus and had
sales over $50,000. The company president would like the sales listed
starting with the highest amount first. The EMPLOYEES table and the
SALES_DEPT table contain the following columns:
EMPLOYEES
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
SALES_DEPT
SALES_ID NUMBER(10) PRIMARY KEY
SALES NUMBER(20)
QUOTA NUMBER(20)
MANAGER VARCHAR2(30)
BONUS NUMBER(10)
EMPLOYEE_ID NUMBER(10) FOREIGN KEY
Which SELECT statement will accomplish this task?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id,
s.bonus, s.sales
FROM employees e, sales_dept s
ORDER BY sales DESC
WHERE e.employee_id = s.employee_id AND sales > 50000 AND s.bonus
IS NOT NULL;
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id,
s.bonus, s. sales
ORDER BY sales DESC
FROM employees e, sales_dept s
WHERE e.employee_id = s.employee_id AND s.bonus IS NOT NULL AND
sales > 50000;
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id,
s.bonus, s. sales
WHERE e.employee_id = s.employee_id
FROM employees e, sales_dept s AND s.bonus IS NOT NULL AND sales >
50000
ORDER BY sales DESC;
SELECT e.employee_id, e.last_name, e.first_name, s.employee_id,
s.bonus, s. sales
FROM employees e, sales_dept s
WHERE e.employee_id = s.employee_id AND s.bonus IS NOT NULL AND
An equijoin
A Cartesian product (*)
Correct
30. You have two tables named EMPLOYEES and SALES. You want to
identify the sales representatives who have generated $100,000, or more,
in revenue. Which query should you issue? Mark for Review
(1) Points
SELECT e.first_name, e.last_name, s.sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue > 100000;
SELECT e.first_name, e.last_name, s.sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue >= 100000;
(*)
SELECT e.first_name, e.last_name, s.sales
FROM employees, sales
WHERE e.employee_id = s.employee_id AND revenue >= 100000;
SELECT first_name, last_name, sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id AND revenue > 100000;
Correct
Section 3 31. Which statement about the join syntax of an Oracle
Proprietary join syntax SELECT statement is true? Mark for Review
(1) Points
The ON keyword must be included.
The JOIN keyword must be included.
The FROM clause represents the join criteria.
display.
Which type of join should you use to display the data? Mark for Review
(1) Points
Natural join
Self-join
Outer join (*)
Equijoin
Correct
35. Using Oracle Proprietary join syntax, which two operators can be used
in an outer join condition using the outer join operator (+)? Mark for Review
(1) Points
AND and = (*)
OR and =
BETWEENAND and IN
IN and =
Correct
36. Evaluate this SELECT statement:
SELECT *
FROM employee e, employee m
WHERE e.manager_id = m.employee_id;
Which type of join is created by this SELECT statement?
Mark for Review
(1) Points
a self join (*)
a cross join
ON c.cust_id = o.cust_id;
(*)
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER orders o
ON c.cust_id = o.cust_id;
Correct
39. Which query will retrieve all the rows in the EMPLOYEES table, even if
there is no match in the DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id =
d.department_id);
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
NATURAL JOIN departments d;
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id =
d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
JOIN departments d USING (e.department_id = d.department_id);
Correct
40. Which of the following best describes a natural join? Mark for Review
(1) Points
A join between two tables that includes columns that share the same name,
datatypes and lengths (*)
A join that produces a Cartesian product
A join between tables where matching fields do not exist
A join that uses only one table
Correct
Section 4 41. Which statement about a natural join is true? Mark for Review
(1) Points
Columns with the same names must have identical data types.
Columns with the same names must have the same precision and
datatype. (*)
Columns with the same names must have compatible data types.
Columns with the same names cannot be included in the SELECT list of
the query.
Correct
42. You need to join two tables that have two columns with the same name,
datatype and precision. Which type of join would you create to join the
tables on both of the columns? Mark for Review
(1) Points
Natural join (*)
Cross join
Outer join
Self-join
Correct
43. The primary advantages of using JOIN ON is: (Select two) Mark for
Review
(1) Points (Choose all correct answers)
The join happens automatically based on matching column names and
data types.
It will display rows that do not meet the join condition.
It permits columns with different names to be joined. (*)
It permits columns that dont have matching data types to be joined. (*)
Correct
44. For which condition would you use an equijoin query with the USING
keyword? Mark for Review
(1) Points
You need to perform a join of the CUSTOMER and ORDER tables but limit
the number of columns in the join condition. (*)
The ORDER table contains a column that has a referential constraint to a
column in the PRODUCT table.
The CUSTOMER and ORDER tables have no columns with identical
names.
The CUSTOMER and ORDER tables have a corresponding column,
CUST_ID. The CUST_ID column in the ORDER table contains null values
that need to be displayed.
Incorrect. Refer to Section 4
45. You created the CUSTOMERS and ORDERS tables by issuing these
CREATE TABLE statements in sequence:
CREATE TABLE customers
(custid varchar2(5),
companyname varchar2(30),
contactname varchar2(30),
address varchar2(30),
city varchar2(20),
state varchar2(30),
phone varchar2(20),
constraint pk_customers_01 primary key (custid));
CREATE TABLE orders
(orderid varchar2(5) constraint pk_orders_01 primary key,
orderdate date,
total number(15),
custid varchar2(5) references customers (custid));
You have been instructed to compile a report to present the information
about orders placed by customers who reside in Nashville. Which query
should you issue to achieve the desired results?
Mark for Review
(1) Points
SELECT custid, companyname
FROM customers
WHERE city = Nashville;
SELECT orderid, orderdate, total
FROM orders o
NATURAL JOIN customers c ON o.custid = c.custid
WHERE city = Nashville;
SELECT orderid, orderdate, total
FROM orders o
JOIN customers c ON o.custid = c.custid
WHERE city = Nashville;
(*)
SELECT orderid, orderdate, total
FROM orders
WHERE city = Nashville;
Correct
46. Below find the structure of the CUSTOMERS and SALES_ORDER
tables:
CUSTOMERS
CUSTOMER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_NAME VARCHAR2 (30)
CONTACT_NAME VARCHAR2 (30)
CONTACT_TITLE VARCHAR2 (20)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (20)
COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the
COUNTRY table
PHONE VARCHAR2 (20)
FAX VARCHAR2 (20)
CREDIT_LIMIT NUMBER(7,2)
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the
CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You need to create a report that displays customers without a sales order.
Which statement could you use?
Mark for Review
(1) Points
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order
s);
(*)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id = s.customer_id(+);
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id (+) = s.customer_id;
SELECT c.customer_name
FROM customers c
RIGHT OUTER JOIN sales_order s
ON (c.customer_id = s.customer_id);
Correct
Section 5 47. Which statement about the GROUP BY clause is true? Mark
for Review
(1) Points
The first column listed in the GROUP BY clause is the most major
grouping. (*)
The last column listed in the GROUP BY clause is the most major grouping.
The GROUP BY clause can contain an aggregate function.
A GROUP BY clause cannot be used without an ORDER BY clause.
Correct
48. If a select list contains both a column as well as a group function then
what clause is required? Mark for Review
(1) Points
HAVING clause
JOIN clause
ORDER BY clause
GROUP BY clause (*)
Correct
49. What is the best explanation as to why this SQL statement will NOT
execute?
SELECT department_id Department, AVG (salary)Average
FROM employees
GROUP BY Department;
Mark for Review
(1) Points
Salaries cannot be averaged as not all the numbers will divide evenly.
You cannot use a column alias in the GROUP BY clause. (*)
The GROUP BY clause must have something to GROUP.
The department id is not listed in the departments table.
Correct
50. What will the following SQL Statement do?
SELECT job_id, COUNT(*)
FROM employees
GROUP BY job_id;
Mark for Review
(1) Points
Displays all the employees and groups them by job.
Displays each job id and the number of people assigned to that job id. (*)
Displays only the number of job_ids.
Displays all the jobs with as many people as there are jobs.
Correct
1. est: Mid Term Exam Semester 2 Part II
2. Review your answers, feedback, and question scores below. An asterisk (*) indicates a
correct answer.
3.
Semester 2 Mid Term Exam Part II covers Sections 5-7 of Database Programming with
SQL.
4.
Section 5
5.
6.
1.
7. (1) Points
8.
9.
10.
11.
12.
13.
Identify the extra row values created by either a ROLLUP or CUBE operation (*)
14.
15.
16.
17.
18.
19.
20. Correct
Correct
21.
22.
23.
2.
used to specify multiple groupings of data but provide a single result set. True or False?
Mark for Review
24. (1) Points
25.
26.
27.
True (*)
28.
29.
30.
False
31.
32.
33.
34. Incorrect
35.
36.
37.
3.
You use GROUPING function to ______ database rows from tabulated rows.
CREATE
42.
43.
44.
DISTINGUISH (*)
45.
46.
47.
COMPUTE
48.
49.
50.
COUNT
51.
52.
53.
54. Incorrect
55.
56.
57.
4.
CUBE will cross-reference the columns listed in the ______ clause to create
a superset of groups.
58. (1) Points
59.
60.
61.
GROUP BY (*)
62.
63.
64.
WHERE
65.
66.
67.
68.
69.
70.
SELECT
71. Correct
Correct
72.
73.
74.
5.
Three
79.
80.
81.
Four
82.
83.
84.
Two (*)
85.
86.
87.
88.
89.
90.
91. Correct
Correct
92.
93.
94.
6.
95.
96. PROD_ID NUMBER(4)
97. PROD_NAME VARCHAR(20)
98. PROD_CAT VARCHAR2(15)
99. PROD_PRICE NUMBER(5)
100.
PROD_QTY NUMBER(4)
101.
102.
You need to identify the minimum product price in each product category.
103.
104.
105.
106.
107.
108.
109.
FROM products
110.
GROUP BY prod_price;
111.
112.
113.
114.
115.
FROM products
116.
GROUP BY prod_cat;
117.
118.
(*)
119.
120.
121.
122.
FROM products
123.
124.
125.
126.
127.
128.
FROM products
129.
GROUP BY prod_cat;
130.
131.
132.
133.
134.
Incorrect
135.
136.
137.
7.
138.
139.
140.
FROM employees
141.
WHERE status = I
142.
GROUP BY dept_id
143.
144.
ORDER BY 2;
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
The ORDER BY clause must specify a column name in the EMPLOYEE table.
161.
162.
163.
164.
Incorrect
165.
166.
167.
168.
8.
(1) Points
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
A query that includes a group function in the SELECT list must include a
GROUP BY clause.
181.
182.
183.
184.
Incorrect
185.
186.
187.
9.
188.
189.
190.
LAST_NAME VARCHAR2(20)
191.
FIRST_NAME VARCHAR2(20)
192.
DEPARTMENT VARCHAR2(20)
193.
HIRE_DATE DATE
194.
SALARY NUMBER(10)
195.
196.
You want to create a report that includes each employees last name, employee
identification number, date of hire and salary. The report should include only those
employees who have been with the company for more than one year and whose salary
exceeds $40,000.
197.
198.
199.
200.
201.
202.
203.
204.
FROM employees
205.
206.
AND hire_date =
207.
(SELECT hire_date
208.
FROM employees
209.
210.
211.
212.
213.
214.
FROM employees
215.
216.
(SELECT hire_date
217.
FROM employees
218.
219.
220.
221.
222.
223.
FROM employees
224.
225.
226.
227.
(*)
228.
229.
230.
231.
FROM employees
232.
233.
234.
235.
236.
237.
Incorrect
238.
239.
240.
10.
241.
242.
FROM employees
243.
GROUP BY job_id;
244.
245.
246.
247.
248.
249.
250.
251.
252.
Displays each job id and the number of people assigned to that job id. (*)
253.
254.
255.
256.
257.
258.
Displays all the jobs with as many people as there are jobs.
259.
260.
261.
262.
Incorrect
263.
264.
Section 5
265.
266.
11.
Mark for
Review
267.
(1) Points
268.
269.
270.
To exclude rows before dividing them into groups using the GROUP BY clause,
274.
275.
276.
277.
278.
279.
280.
You must use the HAVING clause with the GROUP BY clause.
281.
282.
283.
Incorrect
284.
285.
286.
12.
287.
288.
PLAYERS
289.
290.
291.
292.
TEAM_ID NUMBER
293.
294.
295.
TEAMS
296.
297.
298.
299.
You need to create a report that lists the names of each team with more than three
goal keepers.
300.
301.
302.
303.
304.
305.
306.
307.
ON (p.team_id = t.team_id)
308.
309.
GROUP BY t.team_name;
310.
311.
312.
313.
314.
FROM players
315.
316.
317.
318.
319.
320.
321.
322.
323.
ON (p.team_id = t.team_id)
324.
325.
GROUP BY t.team_name
326.
327.
328.
329.
330.
331.
FROM players p
332.
333.
334.
GROUP BY t.team_name
335.
336.
337.
(*)
338.
339.
340.
341.
Incorrect
342.
343.
344.
13.
345.
346.
PAYMENT_ID NUMBER(9) PK
347.
PAYMENT_DATE DATE
348.
CUSTOMER_ID NUMBER(9)
349.
350.
Which SELECT statement could you use to display the number of times each
customer payment was made between January 1, 2003 and June 30, 2003 ?
351.
352.
353.
354.
355.
356.
FROM payment
357.
358.
GROUP BY customer_id;
359.
360.
(*)
361.
362.
363.
SELECT COUNT(payment_id)
364.
FROM payment
365.
366.
367.
368.
369.
370.
FROM payment
371.
372.
373.
374.
375.
SELECT COUNT(payment_id)
376.
FROM payment
377.
378.
GROUP BY customer_id;
379.
380.
381.
382.
383.
384.
385.
Incorrect
386.
14.
You want to write a report that returns the average salary of all
388.
389.
EMPLOYEES:
390.
391.
LNAME VARCHAR2(20)
392.
FNAME VARCHAR2(20)
393.
DEPT VARCHAR2(20)
394.
HIRE_DATE DATE
395.
SALARY NUMBER(10)
396.
397.
Which SELECT statement will return the information that you require?
398.
399.
400.
401.
402.
403.
FROM employees
404.
GROUP BY dept;
405.
406.
407.
408.
409.
FROM employees
410.
GROUP BY dept;
411.
412.
(*)
413.
414.
415.
416.
FROM employees
417.
BY dept;
418.
419.
420.
421.
422.
FROM employees
423.
BY dept;
424.
425.
426.
427.
428.
Incorrect
429.
430.
431.
15.
432.
433.
FROM employees
434.
GROUP BY department_id;
435.
436.
437.
438.
439.
440.
441.
442.
443.
444.
445.
446.
447.
448.
449.
450.
451.
452.
453.
454.
455.
456.
Correct
Correct
457.
16.
458.
459.
460.
FROM employees
461.
462.
463.
464.
ORDER BY department_id;
465.
466.
467.
468.
469.
470.
471.
472.
473.
474.
475.
476.
477.
478.
479.
480.
481.
482.
483.
484.
485.
486.
Incorrect
487.
488.
489.
17.
490.
491.
492.
493.
DEPARTMENT_ID NUMBER
494.
495.
HIRE_DATE DATE
496.
497.
498.
499.
500.
FROM employees
501.
502.
503.
ORDER BY hire_date;
504.
505.
506.
507.
508.
509.
510.
511.
512.
513.
514.
515.
516.
517.
518.
519.
520.
521.
522.
523.
Incorrect
524.
525.
526.
18.
ORDER BY clause is used ______ and is placed in the _____ SELECT statement of the
query. Mark for Review
527.
(1) Points
528.
529.
530.
ONCE; FIRST
531.
532.
533.
TWICE; FIRST
534.
535.
536.
537.
538.
539.
IN ALL; LAST
540.
541.
542.
543.
Incorrect
544.
545.
546.
19.
When using SET operators the number of columns and the data
types of the columns must be identical in all of the SELECT statements used in the query.
True or False?
547.
(1) Points
548.
549.
550.
True (*)
551.
552.
553.
False
554.
555.
556.
557.
558.
559.
560.
Correct
Correct
561.
Section 6
562.
563.
20.
564.
565.
566.
FROM employees
567.
WHERE department_id IN
568.
(SELECT department_id
569.
 FROM employees
570.
571.
572.
573.
574.
575.
576.
577.
578.
579.
580.
581.
582.
583.
All employees who work in a department with employees who earn more than
All employees who work in a department with employees who earn more than
Incorrect
591.
592.
Section 6
593.
594.
21.
595.
596.
597.
598.
FROM employees
599.
WHERE department_id IN
600.
Executive);
601.
602.
603.
604.
605.
The department ID, department name and last name for every employee in the
Executive department.
606.
607.
608.
The department ID, last name, department name for every Executive in the
employees table.
609.
610.
611.
The department ID, last name, job ID from departments for Executive
employees.
612.
613.
614.
The department ID, last name, job ID for every employee in the Executive
department. (*)
615.
616.
617.
618.
Incorrect
619.
620.
621.
22.
622.
623.
624.
FROM players
625.
WHERE team_id IN
626.
(SELECT team_id
627.
 FROM teams
628.
629.
630.
631.
632.
633.
634.
635.
636.
637.
638.
639.
640.
641.
642.
643.
644.
All the rows in the PLAYER table would be returned by the outer query.
645.
646.
647.
648.
Correct
Correct
649.
650.
651.
652.
23.
(1) Points
653.
654.
655.
The WITH clause retrieves the results of one or more query blocks.
656.
657.
658.
659.
660.
661.
662.
663.
664.
Stores the results for the user who runs the query.
665.
666.
667.
668.
Correct
Correct
669.
670.
671.
24.
(1) Points
673.
674.
675.
EVERY TIME
676.
677.
678.
ONCE (*)
679.
680.
681.
COMPLETELY
682.
683.
684.
685.
Incorrect
686.
687.
688.
25.
statement, as long as you start your statement with the keyword WITH. True or False? Mark
for Review
689.
(1) Points
690.
691.
692.
693.
694.
True (*)
695.
False
696.
697.
698.
699.
Correct
Correct
700.
701.
702.
26.
query, _______ the inner query using candidate row value, and _______ values from the
inner query to qualify or disqualify the candidate row. Mark for Review
703.
(1) Points
704.
705.
706.
707.
708.
709.
710.
711.
712.
713.
714.
715.
716.
717.
718.
719.
Incorrect
720.
721.
722.
723.
27.
(1) Points
724.
725.
726.
727.
728.
A query that returns only one row from the inner SELECT statement (*)
729.
A query that returns one or more rows from the inner SELECT statement
730.
731.
732.
A query that returns only one column value from the inner SELECT statement
733.
734.
735.
A query that returns one or more column values from the inner SELECT
statement
736.
737.
738.
739.
Incorrect
740.
741.
742.
28.
(1) Points
744.
745.
746.
No rows (*)
747.
748.
749.
750.
751.
752.
A null value
753.
754.
755.
An error
756.
757.
758.
759.
760.
761.
Incorrect
762.
29.
You need to display all the players whose salaries are greater than
or equal to John Browns salary. Which comparison operator should you use? Mark for
Review
763.
(1) Points
764.
765.
766.
767.
768.
769.
>
770.
771.
772.
<=
773.
774.
775.
>= (*)
776.
777.
778.
779.
Correct
Correct
780.
781.
782.
30.
cost value greater than the average cost of all products. Which SELECT statement should
you use?
783.
(1) Points
784.
785.
786.
SELECT product_name
787.
FROM products
788.
789.
FROM product);
790.
791.
792.
793.
(*)
794.
SELECT product_name
795.
FROM products
796.
797.
798.
799.
800.
801.
FROM products
802.
803.
GROUP by product_name;
804.
805.
806.
807.
SELECT product_name
808.
809.
810.
811.
812.
813.
814.
Incorrect
815.
816.
Section 6
817.
818.
31.
819.
820.
EMPLOYEES
821.
822.
FIRST_NAME VARCHAR2(30)
823.
LAST_NAME VARCHAR2(30)
824.
ADDRESS VARCHAR2(25)
825.
CITY VARCHAR2(20)
826.
STATE VARCHAR2(2)
827.
ZIP NUMBER(9)
828.
TELEPHONE NUMBER(10)
829.
830.
ORDERS
831.
832.
833.
834.
ORDER_DATE DATE
835.
TOTAL NUMBER(10)
836.
837.
Which SELECT statement will return all orders generated by a sales representative
840.
841.
842.
843.
844.
FROM employees
845.
846.
847.
848.
849.
850.
FROM ORDERS
852.
853.
854.
855.
856.
857.
FROM ORDERS
858.
Franklin;
859.
860.
861.
862.
863.
FROM ORDERS
864.
last_name = Franklin)
865.
866.
867.
(*)
868.
869.
870.
871.
Incorrect
872.
873.
874.
row?
875.
32.
Which operator can be used with subqueries that return only one
876.
877.
878.
LIKE (*)
879.
880.
881.
ANY
882.
883.
884.
ALL
885.
886.
887.
IN
888.
889.
890.
891.
Incorrect
892.
893.
894.
33.
If you use the equality operator (=) with a subquery, how many
(1) Points
896.
897.
898.
Only 1 (*)
899.
900.
901.
Up to 2
902.
903.
904.
Up to 5
905.
906.
907.
Unlimited
908.
909.
910.
911.
Incorrect
912.
913.
914.
34.
for Review
915.
(1) Points
916.
917.
918.
IN (*)
919.
920.
921.
<>
922.
923.
924.
925.
926.
927.
928.
929.
930.
LIKE
Mark
931.
Incorrect
932.
933.
934.
35.
execution?
935.
(1) Points
936.
937.
938.
939.
940.
941.
942.
943.
944.
945.
946.
947.
948.
949.
950.
951.
Incorrect
952.
953.
954.
36.
for Review
955.
(1) Points
956.
957.
958.
WHERE
959.
960.
961.
FROM
962.
963.
964.
HAVING
Mark
965.
966.
967.
968.
969.
970.
971.
Incorrect
972.
973.
974.
975.
Section 7
976.
977.
37.
978.
979.
980.
981.
982.
983.
984.
QTY_IN_STOCK NUMBER(4)
985.
986.
987.
988.
989.
990.
991.
992.
993.
994.
995.
(*)
996.
997.
998.
999.
1000.
1001.
1002.
1003.
1004.
1005.
1006.
1007.
1008.
1009.
1010.
1011.
1012.
1013.
1014.
Correct
Correct
1015.
1016.
1017.
38.
EMPLOYEE_HIST table. What could you use in the INSERT statement to accomplish this
task? Mark for Review
1018.
(1) Points
1019.
1020.
1021.
An ON clause
1022.
1023.
1024.
A SET clause
1025.
1026.
1027.
A subquery (*)
1028.
1029.
1030.
A function
1031.
1032.
1033.
1034.
Incorrect
1035.
1036.
1037.
39.
accept null values, how can you implicitly insert a null value in a column? Mark for Review
1038.
(1) Points
1039.
1040.
1041.
1042.
1043.
1044.
1045.
1046.
1047.
1048.
1049.
1050.
1051.
1052.
1053.
1054.
Incorrect
1055.
1056.
1057.
40.
1058.
1059.
PROD_ID NUMBER(4)
1060.
PROD_NAME VARCHAR2(25)
1061.
PROD_PRICE NUMBER(3)
1062.
1063.
You want to add the following row data to the PRODUCTS table:
1064.
1065.
1066.
1067.
1068.
1069.
1070.
1071.
1072.
1073.
1074.
1075.
1076.
1077.
1078.
1079.
The row was created with the correct data in all three columns. (*)
1080.
1081.
1082.
The row was created with the correct data in two of three columns.
1083.
1084.
1085.
The row was created with the correct data in one of the three columns.
1086.
1087.
1088.
The row was created completely wrong. No data ended up in the correct
columns.
1089.
1090.
1091.
1092.
Correct
Correct
1093.
1094.
Section 7
1095.
1096.
41.
columns in the EMPLOYEES table using one UPDATE statement. Which clause should you
include in the UPDATE statement to update multiple columns?
1097.
(1) Points
1098.
1099.
1100.
1101.
1102.
1103.
The ON clause
1104.
1105.
1106.
1107.
1108.
1109.
1110.
1111.
1112.
1113.
Incorrect
1114.
1115.
1116.
42.
that she was recently married, and she has requested that you update her name in the
employee database. Her new last name is Cooper. Janet is the only person with the last
name of Roper that is employed by the company. The EMPLOYEES table contains these
columns and all data is stored in lowercase:
1117.
1118.
1119.
LAST_NAME VARCHAR2(20)
1120.
FIRST_NAME VARCHAR2(20)
1121.
1122.
HIRE_DATE DATE
1123.
SALARY NUMBER(10)
1124.
1125.
1126.
1127.
1128.
1129.
1130.
1131.
UPDATE employees
1132.
1133.
1134.
(*)
1135.
1136.
1137.
1138.
1139.
1140.
1141.
1142.
UPDATE employees
1143.
1144.
1145.
1146.
1147.
1148.
UPDATE employees
1149.
1150.
1151.
1152.
1153.
1154.
1155.
Incorrect
1156.
1157.
1158.
43.
still 189, however, her last name is now Rockefeller. Which SQL statement will allow you to
reflect this change?
1159.
(1) Points
1160.
1161.
1162.
employee_ID = 189;
1163.
1164.
1165.
189;
1166.
1167.
1168.
employee_ID = 189;
1169.
1170.
1171.
= 189; (*)
1172.
1173.
1174.
1175.
Incorrect
1176.
1177.
1178.
44.
You need to update the area code of employees that live in Atlanta.
UPDATE employee
1181.
1182.
1183.
Which of the following should you include in your UPDATE statement to achieve the
desired results?
1184.
1185.
1186.
1187.
1188.
1189.
1190.
1191.
1192.
1193.
1194.
1195.
1196.
1197.
1198.
LIKE At%;
1199.
1200.
1201.
Correct
Correct
1202.
1203.
1204.
45.
(1) Points
1206.
1207.
1208.
1209.
1210.
1211.
1212.
1213.
1214.
1215.
1216.
1217.
1218.
1219.
1220.
1221.
Incorrect
1222.
1223.
1224.
46.
(1) Points
1226.
1227.
1228.
SELECT
1229.
1230.
1231.
1232.
WHERE
1233.
1234.
SET (*)
1235.
1236.
1237.
HAVING
1238.
1239.
1240.
1241.
Incorrect
1242.
1243.
1244.
47.
WHERE clause?
1245.
(1) Points
1246.
1247.
1248.
1249.
1250.
1251.
1252.
1253.
1254.
1255.
1256.
1257.
1258.
1259.
1260.
1261.
Incorrect
1262.
1263.
1264.
48.
columns:
1265.
1266.
TEACHERS
1267.
TEACHER_ID NUMBER(5)
1268.
NAME VARCHAR2(25)
1269.
SUBJECT_ID NUMBER(5)
1270.
HIRE_DATE DATE
1271.
SALARY NUMBER(9,2)
1272.
1273.
CLASS_ASSIGNMENTS
1274.
CLASS_ID NUMBER(5)
1275.
TEACHER_ID NUMBER(5)
1276.
START_DATE DATE
1277.
MAX_CAPACITY NUMBER(3)
1278.
1279.
1280.
1281.
1282.
1283.
1284.
You need to display the start date for each class taught by a given teacher.
1285.
1286.
1287.
You need to create a report to display the teachers who were hired more than
You need to display the names of the teachers who teach classes that start
You need to create a report to display the teachers who teach more classes
Incorrect
1300.
49.
the result?
1301.
(1) Points
1302.
1303.
1304.
1305.
1306.
1307.
1308.
1309.
1310.
1311.
1312.
1313.
1314.
1315.
1316.
1317.
Incorrect
1318.
1319.
1320.
50.
tables:
1321.
1322.
PLAYERS
1323.
1324.
1325.
1326.
TEAM_ID NUMBER
1327.
MGR_ID NUMBER
1328.
SIGNING_BONUS NUMBER(9,2)
1329.
SALARY NUMBER(9,2)
1330.
1331.
MANAGERS
1332.
1333.
1334.
1335.
TEAM_ID NUMBER
1336.
1337.
TEAMS
1338.
1339.
1340.
1341.
1342.
1343.
1344.
1345.
1346.
1347.
1348.
1349.
1350.
1351.
To display the maximum and minimum player salary for each team
1352.
1353.
1354.
To display the names of the managers for all the teams owned by a given owner
(*)
1355.
1356.
1357.
To display each player, their manager, and their team name for all teams with a
Home
About
Incorrect
win2k3test
Just another WordPress.com site
Mid Term Exam Semester 2 Part II
Test: Mid Term Exam Semester 2 Part II
3. You use GROUPING function to ______ database rows from tabulated rows. Mark for Review
(1) Points
CREATE
DISTINGUISH (*)
COMPUTE
COUNT
Incorrect Incorrect. Refer to Section 5 Lesson 2.
4. CUBE will cross-reference the columns listed in the ______ clause to create a superset of groups.
Mark for Review
(1) Points
GROUP BY (*)
WHERE
SELECT
Correct Correct
5. Group functions can be nested to a depth of? Mark for Review
(1) Points
Three
Four
Two (*)
Group functions cannot be nested.
Correct Correct
6. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR(20)
PROD_CAT VARCHAR2(15)
PROD_PRICE NUMBER(5)
PROD_QTY NUMBER(4)
You need to identify the minimum product price in each product category.
Which statement could you use to accomplish this task?
Mark for Review
(1) Points
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_price;
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_cat;
(*)
SELECT MIN (prod_price), prod_cat
FROM products
GROUP BY MIN (prod_price), prod_cat;
SELECT prod_price, MIN (prod_cat)
FROM products
GROUP BY prod_cat;
Incorrect Incorrect. Refer to Section 5 Lesson 1.
7. Evaluate this SELECT statement:
You must use the HAVING clause with the GROUP BY clause.
Incorrect Incorrect. Refer to Section 5 Lesson 1.
12. The PLAYERS and TEAMS tables contain these columns:
PLAYERS
PLAYER_ID NUMBER NOT NULL, PRIMARY KEY
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
TEAM_ID NUMBER
POSITION VARCHAR2 (25)
TEAMS
TEAM_ID NUMBER NOT NULL, PRIMARY KEY
TEAM_NAME VARCHAR2 (25)
You need to create a report that lists the names of each team with more than three goal keepers.
Which SELECT statement will produce the desired result?
Mark for Review
(1) Points
SELECT t.team_name, COUNT(p.player_id)
FROM players p, teams t
ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = GOAL KEEPER
GROUP BY t.team_name;
SELECT t.team_name, COUNT(p.player_id)
FROM players
JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = GOAL KEEPER
HAVING COUNT(p.player_id) > 3;
SELECT t.team_name, COUNT(p.player_id)
FROM players p, teams t
ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = GOAL KEEPER
GROUP BY t.team_name
HAVING COUNT(p.player_id) > 3;
SELECT t.team_name, COUNT(p.player_id)
FROM players p
JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = GOAL KEEPER
GROUP BY t.team_name
HAVING COUNT(p.player_id) > 3;
(*)
Incorrect Incorrect. Refer to Section 5 Lesson 1.
13. The PAYMENT table contains these columns:
PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)
Which SELECT statement could you use to display the number of times each customer payment
was made between January 1, 2003 and June 30, 2003 ?
Mark for Review
(1) Points
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN 01-JAN-2003 AND 30-JUN-2003
GROUP BY customer_id;
(*)
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN 01-JAN-2003 AND 30-JUN-2003;
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN 01-JAN-2003 AND 30-JUN-2003;
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN 01-JAN-2003 AND 30-JUN-2003
GROUP BY customer_id;
Incorrect Incorrect. Refer to Section 5 Lesson 1.
14. You want to write a report that returns the average salary of all employees in the company,
sorted by departments.
The EMPLOYEES table contains the following columns:
EMPLOYEES:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which SELECT statement will return the information that you require?
Mark for Review
(1) Points
SELECT salary (AVG)
FROM employees
GROUP BY dept;
False
Correct Correct
Section 6
20. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
 FROM employees
 WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Mark for Review
(1) Points
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more than $30,000 and more
than $50,000.
All employees who work in a department with employees who earn more than $30,000, but less than
$50,000. (*)
Incorrect Incorrect. Refer to Section 6 Lesson 3.
Section 6
21. You are looking for Executive information using a subquery.
What will the following SQL statement display?
All the rows in the PLAYER table would be returned by the outer query.
Correct Correct
23. Which statement is false? Mark for Review
(1) Points
The WITH clause retrieves the results of one or more query blocks.
The WITH clause decreases performance. (*)
The WITH clause makes the query simple to read .
Stores the results for the user who runs the query.
Correct Correct
24. A correlated subquery is evaluated _____ for each row processed by the parent statement. Mark
for Review
(1) Points
EVERY TIME
ONCE (*)
COMPLETELY
Incorrect Incorrect. Refer to Section 6 Lesson 4.
25. Oracle allows you to write named subqueries in one single statement, as long as you start your
statement with the keyword WITH. True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
26. A correlated subquery will _______ a candidate row from an outer query, _______ the inner
query using candidate row value, and _______ values from the inner query to qualify or disqualify
the candidate row. Mark for Review
(1) Points
CREATE; EXECUTE; USE
DELETE; UPDATE; INSERT
GET; EXECUTE; USE (*)
ROLLUP; GRANT; DROP
Incorrect Incorrect. Refer to Section 6 Lesson 4.
27. Which best describes a single-row subquery? Mark for Review
(1) Points
A query that returns only one row from the inner SELECT statement (*)
A query that returns one or more rows from the inner SELECT statement
A query that returns only one column value from the inner SELECT statement
A query that returns one or more column values from the inner SELECT statement
Incorrect Incorrect. Refer to Section 6 Lesson 2.
28. If a single-row subquery returns a null value and uses the equality comparison operator, what will
the outer query return? Mark for Review
(1) Points
No rows (*)
33. If you use the equality operator (=) with a subquery, how many values can the subquery return?
Mark for Review
(1) Points
Only 1 (*)
Up to 2
Up to 5
Unlimited
Incorrect Incorrect. Refer to Section 6 Lesson 1.
34. Which operator can be used with a multiple-row subquery? Mark for Review
(1) Points
IN (*)
<>
=
LIKE
Incorrect Incorrect. Refer to Section 6 Lesson 1.
35. Which of the following is TRUE regarding the order of subquery execution? Mark for Review
(1) Points
The outer query is executed first
The subquery executes once after the main query
The subquery executes once before the main query (*)
(*)
INSERT INTO products
VALUES (2958, Cable, 8690, 7.09, 4.04, SYSDATE);
INSERT INTO products(product_id, product_name)
VALUES (2958, Cable);
INSERT INTO products(product_id, product_name, supplier_id
VALUES (2958, Cable, 8690, SYSDATE);
Correct Correct
38. You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table. What could
you use in the INSERT statement to accomplish this task? Mark for Review
(1) Points
An ON clause
A SET clause
A subquery (*)
A function
Incorrect Incorrect. Refer to Section 7 Lesson 1.
39. Using the INSERT statement, and assuming that a column can accept null values, how can you
implicitly insert a null value in a column? Mark for Review
(1) Points
Use the NULL keyword.
Use the ON clause
Omit the column in the column list. (*)
41. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the
EMPLOYEES table using one UPDATE statement. Which clause should you include in the UPDATE
statement to update multiple columns? Mark for Review
(1) Points
The USING clause
The ON clause
The WHERE clause
The SET clause (*)
Incorrect Incorrect. Refer to Section 7 Lesson 2.
42. One of the sales representatives, Janet Roper, has informed you that she was recently married,
and she has requested that you update her name in the employee database. Her new last name is
Cooper. Janet is the only person with the last name of Roper that is employed by the company. The
EMPLOYEES table contains these columns and all data is stored in lowercase:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET last_name = cooper
WHERE last_name = roper;
(*)
Which of the following should you include in your UPDATE statement to achieve the desired results?
Mark for Review
(1) Points
UPDATE city = Atlanta;
SET city = Atlanta;
WHERE city = Atlanta; (*)
LIKE At%;
Correct Correct
45. You need to remove a row from the EMPLOYEES table. Which statement would you use? Mark
for Review
(1) Points
UPDATE with a WHERE clause
INSERT with a WHERE clause
DELETE with a WHERE clause (*)
MERGE with a WHERE clause
Incorrect Incorrect. Refer to Section 7 Lesson 2.
46. What keyword in an UPDATE statement speficies the columns you want to change? Mark for
Review
(1) Points
SELECT
WHERE
SET (*)
HAVING
Incorrect Incorrect. Refer to Section 7 Lesson 2.
47. What would happen if you issued a DELETE statement without a WHERE clause? Mark for
Review
(1) Points
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
Only one row would be deleted.
Incorrect Incorrect. Refer to Section 7 Lesson 2.
48. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5)
NAME VARCHAR2(25)
SUBJECT_ID NUMBER(5)
HIRE_DATE DATE
SALARY NUMBER(9,2)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER(5)
TEACHER_ID NUMBER(5)
START_DATE DATE
MAX_CAPACITY NUMBER(3)
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
Mark for Review
(1) Points
To display the names each player on the Lions team
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner (*)
To display each player, their manager, and their team name for all teams with a id value greater than
5000
Incorrect Incorrect. Refer to Section 7 Lesson 2.
Share this:
Facebook1
Related
Follow
Follow win2k3test
Get every new post delivered to your Inbox.
Sign me up
Home
About
win2k3test
Just another WordPress.com site
Mid Term Exam Semester 2 Part I
Mid Term Exam Semester 2 Part II
4. Which SELECT statement will calculate the number of rows in the PRODUCTS table? Mark for
Review
(1) Points
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products;
Correct Correct
5. Which group function would you use to display the total of all salary values in the EMPLOYEES
table? Mark for Review
(1) Points
SUM (*)
AVG
COUNT
MAX
Correct Correct
6. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January, February
and March of 2003.
Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT AVG(payment_amount)
FROM payment
WHERE payment_date
BETWEEN 01-JAN-2003 AND 31-MAR-2003;
(*)
SELECT AVG(payment_amount)
FROM payment;
SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN 01-JAN-2003 and 31-MAR-2003;
SELECT AVG(payment_amount)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
Correct Correct
7. The CUSTOMERS table contains these columns:
CUSTOMER_ID NUMBER(9)
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(30)
CREDIT_LIMIT NUMBER (7,2)
CATEGORY VARCHAR2(20)
You need to calculate the average credit limit for all the customers in each category. The average
should be calculated based on all the rows in the table excluding any customers who have not yet
been assigned a credit limit value. Which group function should you use to calculate this value?
Mark for Review
(1) Points
AVG (*)
SUM
COUNT
STDDEV
Correct Correct
8. Which group function would you use to display the average price of all products in the
PRODUCTS table? Mark for Review
(1) Points
SUM
AVG (*)
COUNT
MAX
Correct Correct
9. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(9,2)
HIRE_DATE DATE
BONUS NUMBER(7,2)
COMM_PCT NUMBER(4,2)
Which three functions could be used with the HIRE_DATE, LAST_NAME, or SALARY columns?
(Choose three.)
Mark for Review
(1) Points
(Choose all correct answers)
MAX (*)
SUM
AVG
MIN (*)
COUNT (*)
Incorrect Incorrect. Refer to Section 5
Section 6
10. Which of the following statements contains a comparison operator that is used to restrict rows
based on a list of values returned from an inner query? Mark for Review
(1) Points
SELECT description
FROM d_types
WHERE code
IN (SELECT type_code FROM d_songs);
SELECT description
FROM d_types
WHERE code = ANY (SELECT type_code FROM d_songs);
SELECT description
FROM d_types
WHERE code <> ALL (SELECT type_code FROM d_songs);
All of the above. (*)
Incorrect Incorrect. Refer to Section 6
Page 1 of 5 Next Summary
Skip navigation elements to page contents
Test: Mid Term Exam Semester 2 Part II
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct
answer.
Part II of the Semester 2 Mid Term Exam covers Sections 5-7 of Database Programming with SQL
curriculum.
Section 6
11. You need to create a SELECT statement that contains a multiple-row subquery, which
comparison operator(s) can you use? Mark for Review
(1) Points
IN, ANY, and ALL (*)
LIKE
BETWEENAND?
=, <, and >
Correct Correct
12. Which of the following is a valid reason why the query below will not execute successfully?
Correct Correct
17. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is used. (*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Correct Correct
18. Evaluate this SELECT statement that includes a subquery:
SELECT last_name, first_name
FROM customer
WHERE area_code IN
(SELECT area_code
FROM sales
WHERE salesperson_id = 20);
Which statement is true about the given subquery?
Mark for Review
(1) Points
The outer query executes before the nested subquery.
The results of the inner query are returned to the outer query. (*)
An error occurs if the either the inner or outer queries do not return a value.
Both the inner and outer queries must return a value, or an error occurs.
Correct Correct
19. Which of the following best describes the meaning of the ANY operator? Mark for Review
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to the first value returned by the subquery
Equal to each value in the list
Correct Correct
20. Evaluate this SELECT statement:
SELECT student_id, last_name, first_name
FROM student
WHERE major_id NOT IN
(SELECT major_id
FROM majors
WHERE department_head_id = 30 AND title = ADJUNCT);
What would happen if the inner query returned a NULL value row?
Mark for Review
(1) Points
A syntax error would be returned.
=
LIKE
Correct Correct
23. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use
subqueries? (Choose two)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity > 0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity >
0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY
teacher_id);
Incorrect Incorrect. Refer to Section 6
24. You need to create a report to display the names of products with a cost value greater than the
average cost of all products. Which SELECT statement should you use? Mark for Review
(1) Points
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost)
FROM product);
(*)
SELECT product_name
FROM products
WHERE cost > AVG(cost);
SELECT AVG(cost), product_name
FROM products
COST NUMBER(7,2)
PRICE NUMBER(7,2)
QUANTITY NUMBER
You display the total of the extended costs for each product category by location.
You need to include only the products that have a price less than $25.00.
The extended cost of each item equals the quantity value multiplied by the cost value.
Which SQL statement will display the desired result?
Mark for Review
(1) Points
SELECT category_id, SUM(cost * quantity) TOTAL,location_id
FROM products
WHERE price > 25.00
GROUP BY category_id, location_id;
SELECT SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY location_id;
SELECT category_id, SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY category_id, location_id;
(*)
SELECT SUM(cost * quantity) TOTAL
FROM products
WHERE price < 25.00;
Incorrect Incorrect. Refer to Section 6
28. Evaluate this SELECT statement:
unique types of manufacturers at each location. Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY location_id;
(*)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer;
SELECT location_id, COUNT(type)
FROM manufacturer
GROUP BY location_id;
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY type;
Correct Correct
32. Evaluate this SELECT statement:
SELECT SUM(salary), department_id, department_name
FROM employees
WHERE department_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
Mark for Review
(1) Points
SELECT
FROM
WHERE
GROUP BY (*)
Correct Correct
33. Evaluate this statement:
SELECT department_id, AVG(salary)
FROM employees
WHERE job_id <> 69879
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000
ORDER BY department_id;
Which clauses restricts the result? (Choose two)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
Correct Correct
34. Examine the following EMPLOYEES table:
EMPLOYEES
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
SUPERVISOR_ID NUMBER(9)
You need to produce a report that contains all employee-related information for those employees
who have Brad Carter as a supervisor. However, you are not sure which supervisor ID belongs to
Brad Carter. Which query should you issue to accomplish this task?
Mark for Review
(1) Points
SELECT *
FROM employees
WHERE supervisor_id = (SELECT supervisor_id
 FROM employees
 WHERE last_name = Carter);
SELECT *
FROM supervisors
WHERE supervisor_id =
(SELECT supervisor_id
 FROM employees
 WHERE last_name = Carter);
SELECT *
FROM supervisors
WHERE supervisor_id =
(SELECT employee_id
 FROM supervisors
 WHERE last_name = Carter);
SELECT *
FROM employees
WHERE supervisor_id =
(SELECT employee_id
 FROM employees
 WHERE last_name = Carter);
(*)
Incorrect Incorrect. Refer to Section 6
35. Examine the structure of the EMPLOYEE, DEPARTMENT, and ORDERS tables.
EMPLOYEE:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
DEPARTMENT:
DEPARTMENT_ID NUMBER(9)
DEPARTMENT_NAME VARCHAR2(25)
CREATION_DATE DATE
ORDERS:
ORDER_ID NUMBER(9)
EMPLOYEE_ID NUMBER(9)
DATE DATE
CUSTOMER_ID NUMBER(9)
You want to display all employees who had an order after the Sales department was established.
Which of the following constructs would you use?
Mark for Review
(1) Points
a group function
a single-row subquery (*)
38. Which of the following represents the correct syntax for an INSERT statement? Mark for Review
(1) Points
INSERT VALUES INTO customers (3178 J. Smith 123 Main Street Nashville TN 37777;
INSERT INTO customers VALUES 3178 J. Smith 123 Main Street Nashville TN 37777;
INSERT INTO customers VALUES (3178, J., Smith, 123 Main Street, Nashville, TN, 37777);
(*)
INSERT customers VALUES 3178, J., Smith, 123 Main Street, Nashville, TN, 37777;
Correct Correct
39. You need to delete a record in the EMPLOYEES table for Tim Jones, whose unique employee
identification number is 348. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(5) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(30)
PHONE NUMBER(10)
Which DELETE statement will delete the appropriate record without deleting any additional records?
Mark for Review
(1) Points
DELETE FROM employees
WHERE employee_id = 348;
(*)
DELETE FROM employees
WHERE last_name = jones;
DELETE *
FROM employees
WHERE employee_id = 348;
DELETE jones
FROM employees;
Correct Correct
40. Examine the structures of the PRODUCTS and SUPPLIERS tables:
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta. Which script should
you use?
Mark for Review
(1) Points
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)
You want to execute one DML statement to change the salary of all employees in department 10 to
equal the new salary of employee number 89898. Currently, all employees in department 10 have
the same salary value. Which statement should you execute?
Mark for Review
(1) Points
UPDATE employees
SET salary = SELECT salary FROM employees WHERE employee_id = 89898;
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898);
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898)
WHERE department_id = 10;
(*)
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898 AND
deptartment_id = 10);
Correct Correct
42. When the WHERE clause is missing in a DELETE statement, what is the result? Mark for
Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
45. You need to remove a row from the EMPLOYEES table. Which statement would you use? Mark
for Review
(1) Points
UPDATE with a WHERE clause
INSERT with a WHERE clause
DELETE with a WHERE clause (*)
MERGE with a WHERE clause
Correct Correct
46. One of the sales representatives, Janet Roper, has informed you that she was recently married,
and she has requested that you update her name in the employee database. Her new last name is
Cooper. Janet is the only person with the last name of Roper that is employed by the company. The
EMPLOYEES table contains these columns and all data is stored in lowercase:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET last_name = cooper
WHERE last_name = roper;
(*)
(*)
INSERT INTO products
VALUES (2958, Cable, 8690, 7.09, 4.04, SYSDATE);
INSERT INTO products(product_id, product_name)
VALUES (2958, Cable);
INSERT INTO products(product_id, product_name, supplier_id
VALUES (2958, Cable, 8690, SYSDATE);
Incorrect Incorrect. Refer to Section 7
Previous Page 5 of 5 Summary
Share this:
Related
5
10
3
You can have as many NOT NULL constraints as you have colum
Correct
45. Which two statements about NOT NULL constraints are true? (Choose two)
The Oracle Server creates a name for an unnamed NOT NULL con
Columns without the NOT NULL constraint can contain null value
CHECK
UNIQUE (*)
NOT NULL
PRIMARY KEY
Correct
48. Primary Key, Foreign Key, Unique Key and Check Constraints can be added
at which two levels? (Choose two)
Null Field
Table (*)
Row
Dictionary
Column (*)
Correct
49. You need to ensure that the LAST_NAME column only contains certain
character values. No numbers or special characters are allowed. Which type
of constraint should you define on the LAST_NAME column?
CHECK (*)
UNIQUE
NOT NULL
PRIMARY KEY
Correct
Mark for Review
(1) Points
Follow
Follow win2k3test
Get every new post delivered to your Inbox.
Sign me up