Oracle
Oracle
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? 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;
Correct
Correct
2.
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
The ORDER BY clause must specify a column name in the EMPLOYEE table.
Correct
Correct
3. 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.
Correct
Correct
4.
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.) Mark for Review (1) Points
GROUP BY MAX(salary)
Incorrect
5.
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
(*)
Correct
Correct
6.
Displays each job id and the number of people assigned to that job id. (*)
Displays all the jobs with as many people as there are jobs.
Correct
Correct
7. Which statement about the GROUP BY clause is true? Mark for Review (1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you should use a WHERE clause. (*)
You must use the HAVING clause with the GROUP BY clause.
Correct
Correct
8.
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 MIN (prod_price), prod_cat FROM products GROUP BY MIN (prod_price), prod_cat;
Correct
Correct
9.
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;
(*)
Correct
Correct
10. 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
(*)
BY dept;
Incorrect 11.
(1) Points
A query that includes a group function in the SELECT list must include a GROUP BY clause.
Correct
Correct
12.
ID_NUMBER NUMBER Primary Key NAME VARCHAR2 (30) DEPARTMENT_ID NUMBER SALARY NUMBER (7,2) HIRE_DATE DATE
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
Correct
Correct
13.
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;
Correct
Correct
14. 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? Mark for Review (1) Points
True (*)
False
Incorrect
15. 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
16. GROUPING SETS is another extension to the GROUP BY clause and is used to specify multiple groupings of data but provide a single result set. True or False? Mark for Review (1) Points
True (*)
False
Correct
Correct
Identify the extra row values created by either a ROLLUP or CUBE operation (*)
Correct
Correct
18. CUBE can be applied to all aggregate functions including AVG, SUM, MIN, MAX, and COUNT. True or False? Mark for Review (1) Points
True (*)
False
Correct
Correct
cross-tabulate values
Correct
Correct
Section 6
20. 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 (*)
A null value
An error
Correct 21.
(1) Points
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
Correct
PARTS: PARTS_ID VARCHAR2(25) PK PARTS_NAME VARCHAR2(50) MANUFACTURERS_ID NUMBER COST NUMBER(5,2) PRICE NUMBER(5,2)
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
23. 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
LIKE
BETWEEN...AND...
Correct
Correct
Which of the following best describes the meaning of the Mark for Review
Correct
Correct
25. When creating a report of all employees earning more than the average salary for their department, a __________ ____________ can be used to first calculate the average salary of each department, and then compare the salary for each employee to the average salary of that employees department. Mark for Review (1) Points
WITH CLAUSE
GROUP BY
Correct
Correct
26. Which answer is incorrect? The parent statement can be: Mark for Review (1) Points
A SELECT statement
An UPDATE statement
A DELETE statement
Correct
Correct
The WITH clause retrieves the results of one or more query blocks.
Stores the results for the user who runs the query.
Correct
Correct
28. 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
29.
greater than or equal to John Brown's salary. Which comparison operator should you use? Mark for Review (1) Points
>
<=
>= (*)
Correct
Correct
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.) Mark for Review (1) Points
(*)
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);
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? Mark for Review
(1) Points
SELECT product_name FROM products WHERE cost > (SELECT AVG(cost) FROM product);
(*)
SELECT AVG(cost), product_name FROM products WHERE cost > AVG(cost) GROUP by product_name;
Correct
Correct
32. 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
Correct
Correct
33. 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')
(*)
Correct
Correct
Mark for
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
35. Which operator can be used with a multiple-row Mark for Review
IN (*)
<>
LIKE
Correct
Correct
36.
ORDER_HISTORY tables:
CUSTOMER CUSTOMER_ID NUMBER(5) NAME VARCHAR2(25) CREDIT_LIMIT NUMBER(8,2) OPEN_DATE DATE ORDER_HISTORY
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 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
Section 7
37.
The statement deletes all the rows from the CUSTOMER table. (*)
The statement removes the structure of the CUSTOMER table from the database.
Correct
Correct
38. 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
(*)
Correct
Correct
39.
EMPLOYEE_ID NUMBER(10) PRIMARY KEY LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) DEPTARTMENT_ID VARCHAR2(20) HIRE_DATE DATE SALARY NUMBER(9,2) BONUS NUMBER(9,2)
You need to increase the salary for all employees in department 10 by 10 percent. You also need to increase the bonus for all employees in department 10 by 15 percent. Which statement should you use? Mark for Review (1) Points
UPDATE employees SET salary = salary * 1.10, bonus = bonus * 1.15 WHERE department_id = 10;
(*)
UPDATE employees SET salary = salary * 1.10 AND bonus = bonus * 1.15 WHERE department_id = 10;
UPDATE employees SET (salary = salary * 1.10) SET (bonus = bonus * 1.15) WHERE department_id = 10;
UPDATE employees SET salary = salary * .10, bonus = bonus * .15 WHERE department_id = 10;
Correct
Correct
40. You need to update the area code of employees that live in Atlanta. Evaluate this partial UPDATE statement:
Which of the following should you include in your UPDATE statement to achieve the desired results?
LIKE 'At%';
Incorrect
41. You want to enter a new record into the CUSTOMERS table. Which two commands can be used to create new rows? Mark for Review (1) Points
INSERT, CREATE
MERGE, CREATE
INSERT, UPDATE
Correct
Correct
42.
PLAYER_ID NUMBER NOT NULL PLAYER_LNAME VARCHAR2(20) NOT NULL PLAYER_FNAME VARCHAR2(10) NOT NULL TEAM_ID NUMBER SALARY NUMBER(9,2)
You need to increase the salary of each player for all players on the Tiger team by 12.5 percent. The TEAM_ID value for the Tiger team is 5960. Which statement should you use? Mark for Review (1) Points
(*)
Correct
Correct
43. 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 ON clause
Correct
Correct
TEACHERS TEACHER_ID NUMBER(5) NAME VARCHAR2(25) SUBJECT_ID NUMBER(5) HIRE_DATE DATE SALARY NUMBER(9,2)
Which scenario would require a subquery to return the desired results? Mark for Review (1) Points
You need to display the start date for each class taught by a given teacher.
You need to create a report to display the teachers who were hired more than five years ago.
You need to display the names of the teachers who teach classes that start within the next week.
You need to create a report to display the teachers who teach more classes than the average number of classes taught by each teacher. (*)
Correct
Correct
45. 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)
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
DELETE FROM products WHERE supplier_id IN (SELECT supplier_id FROM suppliers 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
Correct
46. What keyword in an UPDATE statement speficies the columns you want to change? Mark for Review (1) Points
SELECT
WHERE
SET (*)
HAVING
Correct
Correct
47.
You want to add the following row data to the PRODUCTS table:
(1) a NULL value in the PROD_ID column (2) "6-foot nylon leash" in the PROD_NAME column (3) "10" in the PROD_PRICE column
What row data did you add to the table? Mark for Review (1) Points
The row was created with the correct data in all three columns. (*)
The row was created with the correct data in two of three columns.
The row was created with the correct data in one of the three columns.
The row was created completely wrong. No data ended up in the correct columns.
Correct
Correct
48. Assume all the column names are correct. The following SQL statement will execute which of the following?
location_id) VALUES (70, 'Public Relations', 100, 1700); Mark for Review (1) Points
Correct
Correct
49.
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? Mark for Review (1) Points
All full-time students are inserted into the FT_STUDENTS table. (*)
An error occurs because the INSERT statement does NOT contain a VALUES clause.
Correct
Correct
50. 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
Correct
Correct