Test: Mid Term Exam Semester 2 - Part II ORACLE ACADEMY

by NetPumi2 on January 26th, 2012

96%

Syntax: No syntax
Show lines - Hide lines - Show in textbox - Download
Test: Mid Term Exam Semester 2 - Part II
1.  	The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER NOT NULL 
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
QTY_IN_STOCK NUMBER(4)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE
Which INSERT statement will execute successfully?	
 
 
INSERT INTO products 
VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700);
(*)
 
 
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
 
 
 	 	2.  	You have been instructed to add a new customer to the CUSTOMERS table. Because the new customer has not had a credit check, you should not add an amount to the CREDIT column. 
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10) 
COMPANY VARCHAR2(30) 
CREDIT NUMBER(10) 
POC VARCHAR2(30) 
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?	 Označit pro zhodnocení 
(1) Body 
 
 	 	 	(Vyberte všechny správné odpovědi)	 
 
 
INSERT INTO customers (cust_id, company, poc, location) 
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
(*)
 
 
INSERT INTO customers 
VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');
(*)
 
 
INSERT INTO customers 
VALUES (cust_id, company, credit, poc, location) (200, 'InterCargo', 0, 'tflanders', 'samerica');
 
 
INSERT INTO customers 
VALUES (200, InterCargo, 0, tflanders, samerica);
 
 
 	 	 	 	 	 	Correct
 
 
 	 	3.  	Assume all the column names are correct. The following SQL statement will execute which of the following?
INSERT INTO departments (department_id, department_name, manager_id, location_id) 
VALUES (70, 'Public Relations', 100, 1700);	 Označit pro zhodnocení 
(1) Body 
 
 
100 will be inserted into the department_id column
 
 
1700 will be inserted into the manager_id column
 
 
70 will be inserted into the department_id column (*)
 
 
ムPublic Relationsメ will be inserted into the manager_name column
 
 
 	 	 	 	 	 	Correct
 
 
 	 	4.  	The STUDENTS table contains these columns:
STU_ID NUMBER(9) NOT NULL 
LAST_NAME VARCHAR2 (30) NOT NULL 
FIRST_NAME VARCHAR2 (25) NOT NULL 
DOB DATE 
STU_TYPE_ID VARCHAR2(1) NOT NULL 
ENROLL_DATE DATE
You create another table, named FT_STUDENTS, with an identical structure.You want to insert all full-time students, who have a STU_TYPE_ID value of "F", into the new table. You execute this INSERT statement:
INSERT INTO ft_students 
   (SELECT stu_id, last_name, first_name, dob, stu_type_id, enroll_date 
FROM students 
WHERE UPPER(stu_type_id) = 'F');
What is the result of executing this INSERT statement?	 Označit pro zhodnocení 
(1) Body 
 
 
All full-time students are inserted into the FT_STUDENTS table. (*)
 
 
An error occurs because the FT_STUDENTS table already exists.
 
 
An error occurs because you CANNOT use a subquery in an INSERT statement.
 
 
An error occurs because the INSERT statement does NOT contain a VALUES clause.
 
 
 	 	 	 	 	 	Correct
 
 
 	 	5.  	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?	 Označit pro zhodnocení 
(1) Body 
 
 
UPDATE employees 
SET last_name = 'cooper' 
WHERE last_name = 'roper'; (*)
 
 
UPDATE employees last_name = 'cooper' 
WHERE last_name = 'roper';
 
 
UPDATE employees 
SET last_name = 'roper' 
WHERE last_name = 'cooper';
 
 
UPDATE employees 
SET cooper = 'last_name' 
WHERE last_name = 'roper';
 
 
 	 	 	 	 	 	Correct
 
 
 	 	6.  	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?	 Označit pro zhodnocení 
(1) Body 
 
 
DELETE FROM products 
WHERE supplier_id IN 
(SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ATLANTA');
(*)
 
 
DELETE FROM products 
WHERE UPPER(city) = 'ATLANTA';
 
 
DELETE FROM products 
WHERE supplier_id = 
(SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ATLANTA');
 
 
DELETE FROM suppliers 
WHERE supplier_id IN 
(SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ALANTA');
 
 
 	 	 	 	 	 	Correct
 
 
 	 	7.  	Which of the following represents the correct syntax for an INSERT statement?	 Označit pro zhodnocení 
(1) Body 
 
 
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
 
 
 	 	8.  	Which two commands can be used to modify existing data in a database row?	 Označit pro zhodnocení 
(1) Body 
 
 	 	 	(Vyberte všechny správné odpovědi)	 
 
 
DELETE
 
 
MERGE (*)
 
 
SELECT
 
 
UPDATE (*)
 
 
 	 	 	 	 	 	Correct
 
 
 	 	9.  	One of your employees was recently married. Her employee ID is still 189, however, her last name is now Rockefeller. Which SQL statement will allow you to reflect this change?	 Označit pro zhodnocení 
(1) Body 
 
 
INSERT INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
 
 
INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
 
 
UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
 
 
UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189; (*)
 
 
 	 	 	 	 	 	Correct
 
 
 	 	10.  	When the WHERE clause is missing in a DELETE statement, what is the result?	 Označit pro zhodnocení 
(1) Body 
 
 
All rows are deleted from the table. (*)
 
 
The table is removed from the database.
 
 
An error message is displayed indicating incorrect syntax.
 
 
Nothing. The statement will not execute.
 
 
 	 	 	 	 	 	Correct
 
 
Test: Mid Term Exam Semester 2 - Part II
 
 
Projděte své odpovědi, odezvy a hodnocení otázek dole. Hvězdička (*) značí správnou odpověď.
 
 	Semester 2 Mid Term Exam Part II covers Sections 5-7 of Database Programming with SQL also.	 
 
 	Section 7
 	(Odpovězte na všechny otázky v této části)
 
 	 	11.  	What keyword in an UPDATE statement speficies the columns you want to change?	 Označit pro zhodnocení 
(1) Body 
 
 
SELECT
 
 
WHERE
 
 
SET (*)
 
 
HAVING
 
 
 	 	 	 	 	 	Correct
 
 
 	 	12.  	You need to update the expiration date of products manufactured before June 30th . In which clause of the UPDATE statement will you specify this condition?	 Označit pro zhodnocení 
(1) Body 
 
 
The ON clause
 
 
The WHERE clause (*)
 
 
The SET clause
 
 
The USING clause
 
 
 	 	 	 	 	 	Correct
 
 
 	 	13.  	Aliases can be used with MERGE statements. True or False?	 Označit pro zhodnocení 
(1) Body 
 
 
True (*)
 
 
False
 
 
 	 	 	 	 	 	Correct
 
 
 	 	14.  	Multi-table inserts are used when the same source data should be inserted into _____________ target table.	 Označit pro zhodnocení 
(1) Body 
 
 
Ten
 
 
A very large
 
 
More than one (*)
 
 
A data warehouse
 
 
 	 	 	 	 	 	Correct
 
 
 
 
 	Section 6
 	(Odpovězte na všechny otázky v této části)
 
 	 	15.  	The Oracle server performs a correlated subquery when the subquery references a column from a table referred to in the parent. True or False?	 Označit pro zhodnocení 
(1) Body 
 
 
True (*)
 
 
False
 
 
 	 	 	 	 	 	Correct
 
 
 	 	16.  	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.	 Označit pro zhodnocení 
(1) Body 
 
 
CREATE; EXECUTE; USE
 
 
DELETE; UPDATE; INSERT
 
 
GET; EXECUTE; USE (*)
 
 
ROLLUP; GRANT; DROP
 
 
 	 	 	 	 	 	Incorrect. Refer to Section 6 Lesson 4.
 
 
 	 	17.  	The WITH clause enables a SELECT statement to define the subquery block at the start of the query, process the block just once, label the results, and then refer to the results multiple times. True or False?	 Označit pro zhodnocení 
(1) Body 
 
 
True (*)
 
 
False
 
 
 	 	 	 	 	 	Correct
 
 
 	 	18.  	Which statement is false?	 Označit pro zhodnocení 
(1) Body 
 
 
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
 
 
The WITH clause stores the results for the user who runs the query
 
 
 	 	 	 	 	 	Correct
 
 
 	 	19.  	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
This statement fails when executed:
SELECT payment_date, customer_id, payment_amount 
FROM payment 
WHERE payment_id = 
   (SELECT payment_id 
    FROM payment 
    WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00);
Which change could correct the problem?	 Označit pro zhodnocení 
(1) Body 
 
 
Remove the subquery WHERE clause.
 
 
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
 
 
Include the PAYMENT_ID column in the select list of the outer query.
 
 
Remove the single quotes around the date value in the inner query WHERE clause.
 
 
 	 	 	 	 	 	Correct
 
 
 	 	20.  	Evaluate this SELECT statement:
SELECT player_id, name 
FROM players 
WHERE team_id IN 
   (SELECT team_id 
    FROM teams 
    WHERE team_id > 300 AND salary_cap > 400000);
What would happen if the inner query returned a NULL value?	 Označit pro zhodnocení 
(1) Body 
 
 
No rows would be returned by the outer query. (*)
 
 
A syntax error in the outer query would be returned.
 
 
A syntax error in the inner query would be returned.
 
 
All the rows in the PLAYER table would be returned by the outer query.
 
 
 	 	 	 	 	 	Correct
 
 
 	Stránka 2 z 5	 	 
 
 
 
 
 
Test: Mid Term Exam Semester 2 - Part II
 
 
Projděte své odpovědi, odezvy a hodnocení otázek dole. Hvězdička (*) značí správnou odpověď.
 
 	Semester 2 Mid Term Exam Part II covers Sections 5-7 of Database Programming with SQL also.	 
 
 	Section 6
 	(Odpovězte na všechny otázky v této části)
 
 	 	21.  	Which statement about the ANY operator when used with a multiple-row subquery is true?	 Označit pro zhodnocení 
(1) Body 
 
 
The ANY operator compares every value returned by the subquery. (*)
 
 
The ANY operator can be used with the DISTINCT keyword.
 
 
The ANY operator is a synonym for the ALL operator.
 
 
The ANY operator can be used with the LIKE and IN operators.
 
 
 	 	 	 	 	 	Correct
 
 
 	 	22.  	If a single-row subquery returns a null value and uses the equality comparison operator, what will the outer query return?	 Označit pro zhodnocení 
(1) Body 
 
 
No rows (*)
 
 
All the rows in the table
 
 
A null value
 
 
An error
 
 
 	 	 	 	 	 	Correct
 
 
 	 	23.  	Which statement about the <> operator is true?	 Označit pro zhodnocení 
(1) Body 
 
 
The <> operator is NOT a valid SQL operator.
 
 
The <> operator CANNOT be used in a single-row subquery.
 
 
The <> operator returns the same result as the ANY operator in a subquery.
 
 
The <> operator can be used when a single-row subquery returns only one row. (*)
 
 
 	 	 	 	 	 	Correct
 
 
 	 	24.  	Which statement about subqueries is true?	 Označit pro zhodnocení 
(1) Body 
 
 
Subqueries should be enclosed in double quotation marks.
 
 
Subqueries cannot contain group functions.
 
 
Subqueries are often used in a WHERE clause to return values for an unknown conditional value. (*)
 
 
Subqueries generally execute last, after the main or outer query executes.
 
 
 	 	 	 	 	 	Correct
 
 
 	 	25.  	The EMPLOYEES and ORDERS tables contain these columns:
EMPLOYEES 
EMPLOYEE_ID NUMBER(10) NOT NULL PRIMARY KEY 
FIRST_NAME VARCHAR2(30) 
LAST_NAME VARCHAR2(30) 
ADDRESS VARCHAR2(25) 
CITY VARCHAR2(20) 
STATE VARCHAR2(2) 
ZIP NUMBER(9) 
TELEPHONE NUMBER(10)
ORDERS
ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY 
EMPLOYEE_ID NUMBER(10) NOT NULL FOREIGN KEY 
ORDER_DATE DATE
TOTAL NUMBER(10)
Which SELECT statement will return all orders generated by a sales representative named Franklin during the year 2001?	 Označit pro zhodnocení 
(1) Body 
 
 
SELECT order_id, total 
FROM ORDERS (SELECT employee_id 
FROM employees 
WHERE last_name = 'Franklin') 
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
 
 
SELECT (SELECT employee_id FROM employees WHERE last_name = 'Franklin') AND order_id, total 
FROM ORDERS 
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
 
 
SELECT order_id, employee_id, total 
FROM ORDERS 
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01' AND emp_id = 'Franklin';
 
 
SELECT order_id, total 
FROM ORDERS 
WHERE employee_id = (SELECT employee_id FROM employees WHERE last_name = 'Franklin') 
AND order_date BETWEEN '01-jan-01' AND '31-dec-01';
(*)
 
 
 	 	 	 	 	 	Correct
 
 
 	 	26.  	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) 
DATE 
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use subqueries? (Choose two.)	 Označit pro zhodnocení 
(1) Body 
 
 	 	 	(Vyberte všechny správné odpovědi)	 
 
 
SELECT * 
FROM class_assignments 
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
 
 
SELECT * 
FROM teachers 
WHERE teacher_id = (SELECT teacher_id FROM teachers WHERE class_id = 45963);
(*)
 
 
SELECT * 
FROM teachers 
WHERE teacher_id = (SELECT teacher_id, class_assignments WHERE max_capacity > 0);
 
 
SELECT * 
FROM teachers 
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 1000);
 
 
SELECT * 
FROM class_assignments 
max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id);
 
 
 	 	 	 	 	 	Correct
 
 
 	 	27.  	Which operator can be used with a multiple-row subquery?	 Označit pro zhodnocení 
(1) Body 
 
 
IN (*)
 
 
<>
 
 
=
 
 
LIKE
 
 
 	 	 	 	 	 	Correct
 
 
 	 	28.  	Using a subquery in which clause will return a syntax error?	 Označit pro zhodnocení 
(1) Body 
 
 
WHERE
 
 
FROM
 
 
HAVING
 
 
You can use subqueries in all of the above clauses. (*)
 
 
 	 	 	 	 	 	Correct
 
 
 	 	29.  	Which operator can be used with subqueries that return only one row?	 Označit pro zhodnocení 
(1) Body 
 
 
LIKE (*)
 
 
ANY
 
 
ALL
 
 
IN
 
 
 	 	 	 	 	 	Correct
 
 
 	 	30.  	Which of the following is TRUE regarding the order of subquery execution?	 Označit pro zhodnocení 
(1) Body 
 
 
The outer query is executed first
 
 
The subquery executes once after the main query
 
 
The subquery executes once before the main query (*)
 
 
The result of the main query is used with the subquery
 
 
 	 	 	 	 	 	Correct
 
 
 	Stránka 3 z 5	 	 
 
 
 
 
 
Test: Mid Term Exam Semester 2 - Part II
 
 
Projděte své odpovědi, odezvy a hodnocení otázek dole. Hvězdička (*) značí správnou odpověď.
 
 	Semester 2 Mid Term Exam Part II covers Sections 5-7 of Database Programming with SQL also.	 
 
 	Section 6
 	(Odpovězte na všechny otázky v této části)
 
 	 	31.  	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?	 Označit pro zhodnocení 
(1) Body 
 
 
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 
WHERE cost > AVG(cost) 
GROUP by product_name;
 
 
SELECT product_name 
FROM (SELECT AVG(cost) FROM product) 
WHERE cost > AVG(cost);
 
 
 	 	 	 	 	 	Correct
 
 
 
 
 	Section 5
 	(Odpovězte na všechny otázky v této části)
 
 	 	32.  	You use ROLLUP to:	 Označit pro zhodnocení 
(1) Body 
 
 
produce subtotal values (*)
 
 
cross-tabulate values
 
 
produce a single result set
 
 
 	 	 	 	 	 	Correct
 
 
 	 	33.  	CUBE can be applied to all aggregate functions including AVG, SUM, MIN, MAX, and COUNT. True or False?	 Označit pro zhodnocení 
(1) Body 
 
 
True (*)
 
 
False
 
 
 	 	 	 	 	 	Correct
 
 
 	 	34.  	You use GROUPING function to:	 Označit pro zhodnocení 
(1) Body 
 
 
Produce subtotal and cross-tabulated values
 
 
Identify the extra row values created by either a ROLLUP or CUBE operation (*)
 
 
Aggregate rows using SUM, MIN, MAX, and COUNT
 
 
 	 	 	 	 	 	Correct
 
 
 	 	35.  	You use GROUPING function to ______ database rows from tabulated rows.	 Označit pro zhodnocení 
(1) Body 
 
 
CREATE
 
 
DISTINGUISH (*)
 
 
COMPUTE
 
 
COUNT
 
 
 	 	 	 	 	 	Correct
 
 
 	 	36.  	The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER(9) PK 
CATEGORY_ID VARCHAR2(10) 
LOCATION_ID NUMBER(9) 
DESCRIPTION VARCHAR2(30) 
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?	 Označit pro zhodnocení 
(1) Body 
 
 
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 <br /> GROUP BY location_id;
 
 
SELECT category_id, SUM(cost * quantity) TOTAL, location_id 
FROM products 
WHERE price < 25.00 <br /> GROUP BY category_id, location_id;
(*)
 
 
SELECT SUM(cost * quantity) TOTAL 
FROM products 
WHERE price < 25.00;
 
 
 	 	 	 	 	 	Correct
 
 
 	 	37.  	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?	 Označit pro zhodnocení 
(1) Body 
 
 
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;
 
 
 	 	 	 	 	 	Correct
 
 
 	 	38.  	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?	 Označit pro zhodnocení 
(1) Body 
 
 
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;
(*)
 
 
 	 	 	 	 	 	Correct
 
 
 	 	39.  	Evaluate this SELECT statement:
SELECT SUM(salary), department_id, manager_id 
FROM employees 
GROUP BY department_id, manager_id;
Which SELECT clause allows you to restrict the rows returned, based on a group function?	 Označit pro zhodnocení 
(1) Body 
 
 
HAVING SUM(salary) > 100000 (*)
 
 
WHERE SUM(salary) > 100000
 
 
WHERE salary > 100000
 
 
HAVING salary > 100000
 
 
 	 	 	 	 	 	Correct
 
 
 	 	40.  	Evaluate this SELECT statement: 
SELECT MAX(salary), department_id 
FROM employees 
GROUP BY department_id;
Which values are displayed?	 Označit pro zhodnocení 
(1) Body 
 
 
The highest salary for all employees.
 
 
The highest salary in each department. (*)
 
 
The employees with the highest salaries.
 
 
The employee with the highest salary for each department.
 
 
 	 	 	 	 	 	Correct
 
 
 	Stránka 4 z 5	 	 
 
 
 
 
 
Test: Mid Term Exam Semester 2 - Part II
 
 
Projděte své odpovědi, odezvy a hodnocení otázek dole. Hvězdička (*) značí správnou odpověď.
 
 	Semester 2 Mid Term Exam Part II covers Sections 5-7 of Database Programming with SQL also.	 
 
 	Section 5
 	(Odpovězte na všechny otázky v této části)
 
 	 	41.  	Evaluate this SELECT statement:
SELECT COUNT(employee_id), department_id 
FROM employees 
GROUP BY department_id;
You only want to include employees who earn more than 15000. 
Which clause should you include in the SELECT statement?	 Označit pro zhodnocení 
(1) Body 
 
 
WHERE salary > 15000 (*)
 
 
HAVING salary > 15000
 
 
WHERE SUM(salary) > 15000
 
 
HAVING SUM(salary) > 15000
 
 
 	 	 	 	 	 	Correct
 
 
 	 	42.  	What is the correct order of clauses in a SELECT statement?	 Označit pro zhodnocení 
(1) Body 
 
 
SELECT 
FROM 
WHERE 
ORDER BY 
GROUP BY 
HAVING
 
 
SELECT 
FROM 
HAVING 
GROUP BY 
WHERE 
ORDER BY
 
 
SELECT 
FROM 
WHERE 
GROUP BY 
HAVING 
ORDER BY
(*)
 
 
SELECT 
FROM 
WHERE 
HAVING 
ORDER BY 
GROUP BY
 
 
 	 	 	 	 	 	Correct
 
 
 	 	43.  	The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key 
NAME VARCHAR2 (30) 
DEPARTMENT_ID NUMBER 
SALARY NUMBER (7,2) 
HIRE_DATE DATE
Evaluate this SQL statement:
SELECT id_number, name, department_id, SUM(salary) 
FROM employees 
WHERE salary > 25000 
GROUP BY department_id, id_number, name 
ORDER BY hire_date;
Why will this statement cause an error?	 Označit pro zhodnocení 
(1) Body 
 
 
The HAVING clause is missing.
 
 
The WHERE clause contains a syntax error.
 
 
The SALARY column is NOT included in the GROUP BY clause.
 
 
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
 
 
 	 	 	 	 	 	Correct
 
 
 	 	44.  	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.	 Označit pro zhodnocení 
(1) Body 
 
 	 	 	(Vyberte všechny správné odpovědi)	 
 
 
SELECT department_id, AVG(salary)
 
 
WHERE job_id <> 69879 (*)
 
 
GROUP BY job_id, department_id
 
 
HAVING AVG(salary) > 35000 (*)
 
 
 	 	 	 	 	 	Correct
 
 
 	 	45.  	Which statement about group functions is true?	 Označit pro zhodnocení 
(1) Body 
 
 
Group functions ignore null values. (*)
 
 
Group functions can only be used in a SELECT list.
 
 
Group functions can be used in a WHERE clause.
 
 
A query that includes a group function in the SELECT list must include a GROUP BY clause.
 
 
 	 	 	 	 	 	Correct
 
 
 	 	46.  	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 ?	 Označit pro zhodnocení 
(1) Body 
 
 
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;
 
 
 	 	 	 	 	 	Correct
 
 
 	 	47.  	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;	 Označit pro zhodnocení 
(1) Body 
 
 
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
 
 
 	 	48.  	The PLAYERS table contains these columns:
PLAYER_ID NUMBER PK 
PLAYER_NAME VARCHAR2 (30) 
TEAM_ID NUMBER 
HIRE_DATE DATE 
SALARY NUMBER (8,2)
Which clauses represent valid uses of aggregate functions? (Choose three.)	 Označit pro zhodnocení 
(1) Body 
 
 	 	 	(Vyberte všechny správné odpovědi)	 
 
 
ORDER BY AVG(salary) (*)
 
 
GROUP BY MAX(salary)
 
 
SELECT AVG(NVL(salary, 0)) (*)
 
 
HAVING MAX(salary) > 10000 (*)
 
 
WHERE hire_date > AVG(hire_date)
 
 
 	 	 	 	 	 	Correct
 
 
 	 	49.  	To control the order of rows returned using SET operators, the ORDER BY clause is used ______ and is placed in the _____ SELECT statement of the query.	 Označit pro zhodnocení 
(1) Body 
 
 
ONCE; FIRST
 
 
TWICE; FIRST
 
 
ONCE; LAST (*)
 
 
IN ALL; LAST
 
 
 	 	 	 	 	 	Correct
 
 
 	 	50.  	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.	 Označit pro zhodnocení 
(1) Body 
 
 
True (*)
 
 
False
 
 
 	 	 	 	 	 	Incorrect. Refer to Section 5 Lesson 3.
 
 
 	Stránka 5 z 5	 
 
 
 
 
 
3 Comments
  1. bzz permalink

    9. Using MERGE accomplishes an __________ ad __________ simultaneously. Mark for Review
    (1) Points

    INSERT; UPDATE (*)

  2. bzz permalink

    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. Refer to Section 5 Lesson 1.

  3. Alin permalink

    1. Which comparison operator can only be used with a single-row subquery? Mark for Review
    (1) Points

    ANY

    ALL

    (*)

    IN

    Correct Correct

    2. 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

    Correct Correct

    3. 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

    The WITH clause stores the results for the user who runs the query

    Correct Correct

    4. Which answer is incorrect? The parent statement can be: Mark for Review
    (1) Points

    A SELECT statement

    An INSERT statement (*)

    An UPDATE statement

    A DELETE statement

    Correct Correct

    5. A correlated subquery is evaluated _____ for each row processed by the parent statement. Mark for Review
    (1) Points

    EVERY TIME

    ONCE (*)

    COMPLETELY

    Correct Correct

    6. The WITH clause enables a SELECT statement to define the subquery block at the start of the query, process the block just once, label the results, and then refer to the results multiple times. True or False? Mark for Review
    (1) Points

    True (*)

    False

    Correct Correct

    7. You need to display all the players whose salaries are greater than or equal to John Brown’s salary. Which comparison operator should you use? Mark for Review
    (1) Points

    =

    >

    = (*)

    Correct Correct

    8. Using a subquery in which clause will return a syntax error? Mark for Review
    (1) Points

    WHERE

    FROM

    HAVING

    You can use subqueries in all of the above clauses. (*)

    Correct Correct

    9. 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
    WHERE cost > AVG(cost)
    GROUP by product_name;

    SELECT product_name
    FROM (SELECT AVG(cost) FROM product)
    WHERE cost > AVG(cost);

    Correct Correct

    10. 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 (*)

    The result of the main query is used with the subquery

    Correct Correct

    Examine the structures of the CUSTOMER and ORDER_HISTORY tables:

    CUSTOMER
    CUSTOMER_ID NUMBER(5)
    NAME VARCHAR2(25)
    CREDIT_LIMIT NUMBER(8,2)
    OPEN_DATE DATE
    ORDER_HISTORY

    ORDER_ID NUMBER(5)
    CUSTOMER_ID NUMBER(5)
    ORDER_DATE DATE
    TOTAL NUMBER(8,2)

    Which of the following scenarios would require a subquery to return the desired results?
    Mark for Review
    (1) Points

    You need to display the date each customer account was opened.

    You need to display each date that a customer placed an order.

    You need to display all the orders that were placed on a certain date.

    You need to display all the orders that were placed on the same day as order number 25950. (*)

    Correct Correct

    12. Which statement about subqueries is true? Mark for Review
    (1) Points

    Subqueries should be enclosed in double quotation marks.

    Subqueries cannot contain group functions.

    Subqueries are often used in a WHERE clause to return values for an unknown conditional value. (*)

    Subqueries generally execute last, after the main or outer query executes.

    Correct Correct

    13. Which operator can be used with a multiple-row subquery? Mark for Review
    (1) Points

    IN (*)

    =

    LIKE

    Correct Correct

    14. The EMPLOYEES and ORDERS tables contain these columns:

    EMPLOYEES
    EMPLOYEE_ID NUMBER(10) NOT NULL PRIMARY KEY
    FIRST_NAME VARCHAR2(30)
    LAST_NAME VARCHAR2(30)
    ADDRESS VARCHAR2(25)
    CITY VARCHAR2(20)
    STATE VARCHAR2(2)
    ZIP NUMBER(9)
    TELEPHONE NUMBER(10)

    ORDERS

    ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY
    EMPLOYEE_ID NUMBER(10) NOT NULL FOREIGN KEY
    ORDER_DATE DATE
    TOTAL NUMBER(10)

    Which SELECT statement will return all orders generated by a sales representative named Franklin during the year 2001?
    Mark for Review
    (1) Points

    SELECT order_id, total
    FROM ORDERS (SELECT employee_id
    FROM employees
    WHERE last_name = ‘Franklin’)
    WHERE order_date BETWEEN ‘01-jan-01′ AND ‘31-dec-01′;

    SELECT (SELECT employee_id FROM employees WHERE last_name = ‘Franklin’) AND order_id, total
    FROM ORDERS
    WHERE order_date BETWEEN ‘01-jan-01′ AND ‘31-dec-01′;

    SELECT order_id, employee_id, total
    FROM ORDERS
    WHERE order_date BETWEEN ‘01-jan-01′ AND ‘31-dec-01′ AND emp_id = ‘Franklin’;

    SELECT order_id, total
    FROM ORDERS
    WHERE employee_id = (SELECT employee_id FROM employees WHERE last_name = ‘Franklin’)
    AND order_date BETWEEN ‘01-jan-01′ AND ‘31-dec-01′;

    (*)

    Correct Correct

    15. Examine the structures of the PARTS and MANUFACTURERS tables:

    PARTS:
    PARTS_ID VARCHAR2(25) PK
    PARTS_NAME VARCHAR2(50)
    MANUFACTURERS_ID NUMBER
    COST NUMBER(5,2)
    PRICE NUMBER(5,2)

    MANUFACTURERS:
    ID NUMBER PK
    NAME VARCHAR2(30)
    LOCATION VARCHAR2(20)

    Which SQL statement correctly uses a subquery?
    Mark for Review
    (1) Points

    UPDATE parts SET price = price * 1.15
    WHERE manufacturers_id =
    (SELECT id
    FROM manufacturers
    WHERE UPPER(location) IN(’ ATLANTA ‘, ム BOSTON ‘, ム DALLAS ‘));

    SELECT parts_name, price, cost
    FROM parts
    WHERE manufacturers_id !=
    (SELECT id
    FROM manufacturers
    WHERE LOWER(name) = ‘cost plus’);

    SELECT parts_name, price, cost
    FROM parts
    WHERE manufacturers_id IN
    (SELECT id
    FROM manufacturers m
    JOIN part p
    ON (m.id = p.manufacturers_id));

    (*)

    SELECT parts_name
    FROM (SELECT AVG(cost) FROM manufacturers)
    WHERE cost > AVG(cost);

    Correct Correct

    16. 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

    17. 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 10000 (*)

    WHERE hire_date > AVG(hire_date)

    Correct Correct

    39. Evaluate this SELECT statement:

    SELECT SUM(salary), department_id, manager_id
    FROM employees
    GROUP BY department_id, manager_id;

    Which SELECT clause allows you to restrict the rows returned, based on a group function?
    Mark for Review
    (1) Points

    HAVING SUM(salary) > 100000 (*)

    WHERE SUM(salary) > 100000

    WHERE salary > 100000

    HAVING salary > 100000

    Correct Correct

    40. The MANUFACTURER table contains these columns:

    MANUFACTURER_ID NUMBER
    MANUFACTURER_NAME VARCHAR2(30)
    TYPE VARCHAR2(25)
    LOCATION_ID NUMBER

    You need to display the number of 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;

    41. 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.

    42. 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 Correct

    43. Which statement about group functions is true? Mark for Review
    (1) Points

    Group functions ignore null values. (*)

    Group functions can only be used in a SELECT list.

    Group functions can be used in a WHERE clause.

    A query that includes a group function in the SELECT list must include a GROUP BY clause.

    Correct Correct

    44. 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

    45. Evaluate this SELECT statement:

    SELECT COUNT(emp_id), mgr_id, dept_id
    FROM employees
    WHERE status = ‘I’
    GROUP BY dept_id
    HAVING salary > 30000
    ORDER BY 2;

    Why does this statement return a syntax error?
    Mark for Review
    (1) Points

    MGR_ID must be included in the GROUP BY clause. (*)

    The HAVING clause must specify an aggregate function.

    A single query cannot contain a WHERE clause and a HAVING clause.

    The ORDER BY clause must specify a column name in the EMPLOYEE table.

    Correct Correct

    46. The EMPLOYEES table contains these columns:

    ID_NUMBER NUMBER Primary Key
    NAME VARCHAR2 (30)
    DEPARTMENT_ID NUMBER
    SALARY NUMBER (7,2)
    HIRE_DATE DATE

    Evaluate this SQL statement:

    SELECT id_number, name, department_id, SUM(salary)
    FROM employees
    WHERE salary > 25000
    GROUP BY department_id, id_number, name
    ORDER BY hire_date;

    Why will this statement cause an error?
    Mark for Review
    (1) Points

    The HAVING clause is missing.

    The WHERE clause contains a syntax error.

    The SALARY column is NOT included in the GROUP BY clause.

    The HIRE_DATE column is NOT included in the GROUP BY clause. (*)

    Correct Correct

    47. 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;

    SELECT AVG (salary)
    FROM employees
    GROUP BY dept;

    (*)

    SELECT AVG (salary)
    FROM employees
    BY dept;

    SELECT AVG salary
    FROM employees
    BY dept;

    Correct Correct

    48. Evaluate this SELECT statement:

    SELECT COUNT(employee_id), department_id
    FROM employees
    GROUP BY department_id;

    You only want to include employees who earn more than 15000.
    Which clause should you include in the SELECT statement?
    Mark for Review
    (1) Points

    WHERE salary > 15000 (*)

    HAVING salary > 15000

    WHERE SUM(salary) > 15000

    HAVING SUM(salary) > 15000

    Correct Correct

    49. When using SET operators the names of the columns must be identified in all of the SELECT statements used in the query. True or False? Mark for Review
    (1) Points

    True

    False (*)

    Correct Correct

    50. The ___________ operator returns all rows from both tables, after eliminating duplicates. Mark for Review
    (1) Points

    UNION (*)

    UNION ALL

    INTERSECT

    MINUS

    Correct Correct

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS