Test
Test
An asterisk (*) indicates a correct answer. Section 1 (Answer all questions in this section) 1. (1) Points Which comparison operator retrieves a list of values? Mark for Review
IN (*)
LIKE
IS NULL
Correct
Correct
2. 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
Correct
3. Which two functions can be used to manipulate number or date column values, but NOT character column values? (Choose two.) Mark for Review (1) Points (Choose all correct answers)
RPAD
TRUNC (*)
ROUND (*)
INSTR
CONCAT
Correct
Correct
Which value is returned by the query? Mark for Review (1) Points
Correct
Correct
5. 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
Correct
6. (1) Points
Correct
Correct
Which of the following Date Functions will add calendar months to a date?
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Correct
Correct
8. You need to display the number of months between today's date and each employee's hiredate. Which function should you use? Mark for Review (1) Points
ROUND
BETWEEN
ADD_MONTHS
MONTHS_BETWEEN (*)
Correct
Correct
You query the database and return the value 95. Which script did you use? Mark for Review (1) Points
Correct
Correct
10. Evaluate this SELECT statement: SELECT LENGTH(email) FROM employee; What will this SELECT statement display? Mark for Review (1) Points
The number of characters for each value in the EMAIL column in the employees table (*)
Correct
Correct
Page 1 of 5
Next
Summary
Test: Mid Term Exam Semester 2 Part 1 Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer. Section 1 (Answer all questions in this section) 11. 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
Correct
Correct
12. Which functions can be used to manipulate character, number, and date column values? Mark for Review (1) Points
Correct
Correct
13. You issue this SQL statement: SELECT INSTR ('organizational sales', 'al') FROM dual; Which value is returned by this command? Mark for Review (1) Points
13 (*)
17
Correct
Correct
14. You need to display each employee's name in all uppercase letters. Which function should you use? Mark for Review (1) Points
CASE
UCASE
UPPER (*)
TOUPPER
Incorrect
15. What will the following SQL statemtent display? SELECT last_name, LPAD(salary, 15, '$')SALARY FROM employees; Mark for Review (1) Points
The last name of employees that have a salary that includes a $ in the value, size of 15 and the column labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of the decimal and the column labeled SALARY.
The last name and salary for all employees with the format of the salary 15 characters long, leftpadded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where expected."
Incorrect
16. Which SQL function can be used to remove heading or trailing characters (or both) from a character string? Mark for Review (1) Points
LPAD
CUT
NVL2
TRIM (*)
Correct
Correct
Section 2 (Answer all questions in this section) 17. Which of the following General Functions will return the first non-null expression in the expression list? Mark for Review (1) Points
NVL
NVL2
NULLIF
COALESCE (*)
Incorrect
18. You need to replace null values in the DEPT_ID column with the text "N/A". Which functions should you use? Mark for Review (1) Points
Incorrect
19. The PRODUCT table contains this column: PRICE NUMBER(7,2) Evaluate this statement: SELECT NVL(10 / price, '0') FROM PRODUCT; What would happen if the PRICE column contains null values? Mark for Review (1) Points
Incorrect
20. 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 895840 SANDAL 85940 12.00 968950 SANDAL 85909 10.00 758960 SANDAL 86979
COST
STYLE_ID STYLE_NAME 895840 SANDAL 85909 968950 SANDAL 85909 869506 SANDAL 89690 758960 SANDAL 86979
COST
STYLE_ID STYLE_NAME 895840 SANDAL 85909 968950 SANDAL 85909 758960 SANDAL 86979 869506 SANDAL 89690
COST
STYLE_ID STYLE_NAME CATEGORY 968950 SANDAL 85909 10.00 895840 SANDAL 85940 12.00
COST
86979
Incorrect
Previous
Page 2 of 5
Next
Summary
Test: Mid Term Exam Semester 2 Part 1 Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer. Section 2 (Answer all questions in this section) 21. Review (1) Points Which statement concerning single row functions is true? Mark for
Single row functions can accept only one argument, but can return multiple values.
Incorrect
22. Which SQL Statement should you use to display the prices in this format: Mark for Review
Correct
Correct
Mark for
NEXT_DAY(hire_date) + 5
SYSDATE - 6
SYSDATE + 30 / 24
Correct
Correct
24. If you use the RR format when writing a query using the date 27-OCT-17 and the year is 2001, what year would be the result? Mark for Review (1) Points
2001
1901
2017 (*)
1917
Incorrect
Mark
Incorrect
26. All Human Resources data is stored in a table named EMPLOYEES. You have been asked to create a report that displays each employee's name and salary. Each employee's salary
must be displayed in the following format: $000,000.00. Which function should you include in a SELECT statement to achieve the desired result? Mark for Review (1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Correct
Correct
Section 3 (Answer all questions in this section) 27. Review (1) Points Which query represents the correct syntax for a left outer join? Mark for
SELECT companyname, orderdate, total FROM customers c LEFT JOIN orders o ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total FROM customers c OUTER JOIN orders o 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;
Incorrect
28. What types of joins will return the unmatched values from both tables in the join? Mark for Review (1) Points
Natural joins
Incorrect
29. You need to join the EMPLOYEE_HIST and EMPLOYEES tables. The EMPLOYEE_HIST table will be the first table in the FROM clause. All the matched and unmatched rows in the EMPLOYEES table need to be displayed. Which type of join will you use? Mark for Review (1) Points
A cross join
An inner join
Incorrect
SELECT p.part_id, t.product_id FROM part p, part t WHERE p.part_id = t.product_id; (*)
SELECT p.part_id, t.product_id FROM part p, product t WHERE p.part_id = t.product_id (+);
Correct
Correct
Previous
Page 3 of 5
Next
Summary
Test: Mid Term Exam Semester 2 Part 1 Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer. Section 3 (Answer all questions in this section) 31. Evaluate this SELECT statement: SELECT * FROM employee e, employee m WHERE e.mgr_id = m.emp_id; Which type of join is created by this SELECT statement? Mark for Review (1) Points
a cross join
Correct
Correct
Incorrect
For which condition would you use an equijoin query with the USING keyword?
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.
Correct
Correct
34. Evaluate this SELECT statement: SELECT a.lname || ', ' || a.fname as "Patient", b.lname || ', ' || b.fname as "Physician", c.admission FROM patient a JOIN physician b ON (b.physician_id = c.physician_id) JOIN admission c
ON (a.patient_id = c.patient_id); Which clause generates an error? Mark for Review (1) Points
JOIN physician b
JOIN admission c
ON (a.patient_id = c.patient_id)
Incorrect
35. Which keyword in a SELECT statement creates an equijoin by specifying a column name common to both tables? Mark for Review (1) Points
A HAVING clause
Incorrect
36. Below find the structures of the PRODUCTS and VENDORS tables: PRODUCTS PRODUCT_ID NUMBER PRODUCT_NAME VARCHAR2 (25) VENDOR_ID NUMBER CATEGORY_ID NUMBER VENDORS VENDOR_ID NUMBER VENDOR_NAME VARCHAR2 (25) ADDRESS VARCHAR2 (30) CITY VARCHAR2 (25) REGION VARCHAR2 (10) POSTAL_CODE VARCHAR2 (11) You want to create a query that will return an alphabetical list of products, including the product name and associated vendor name, for all products that have a vendor assigned. Which two queries could you use? Mark for Review (1) Points (Choose all correct answers)
SELECT p.product_name, v.vendor_name FROM products p LEFT OUTER JOIN vendors v ON p.vendor_id = v.vendor_id ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name FROM products p JOIN vendors v ON (vendor_id) ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name FROM products p JOIN vendors v USING (p.vendor_id) ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name FROM products p JOIN vendors v USING (vendor_id) ORDER BY p.product_name; (*)
Incorrect
Mark for
The join happens automatically based on matching column names and data types.
It permits columns that don?t have matching data types to be joined. (*)
Incorrect
A join condition that includes the (+) on the left hand side
Correct
Correct
39. 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 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'; (*)
Incorrect
Section 4 (Answer all questions in this section) 40. Which group functions below act on character, number, and date data types? (Choose all that are correct.) Mark for Review (1) Points
SUM
MAX (*)
MIN (*)
AVG
COUNT (*)
Incorrect
Previous
Page 4 of 5
Next
Summary
Test: Mid Term Exam Semester 2 Part 1 Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer. Section 4 (Answer all questions in this section) 41. You need to calculate the standard deviation for the cost of products produced in the Birmingham facility. Which group function will you use? Mark for Review (1) Points
STDEV
STDDEV (*)
VAR_SAMP
VARIANCE
Incorrect
42. Which group function would you use to display the lowest value in the SALES_AMOUNT column? Mark for Review (1) Points
AVG
COUNT
MAX
MIN (*)
Incorrect
43. The VENDORS table contains these columns: VENDOR_ID NUMBER Primary Key NAME VARCHAR2(30) LOCATION_ID NUMBER ORDER_DT DATE ORDER_AMOUNT NUMBER(8,2) Which two clauses represent valid uses of aggregate functions for this table? Mark for Review (1) Points (Choose all correct answers)
FROM MAX(order_dt)
SELECT SUM(order_dt)
Incorrect
Which group function would you use to display the highest salary value in the Mark for Review
AVG
COUNT
MAX (*)
MIN
Incorrect
PAYMENT_ID 86590586
45. Examine the data in the PAYMENT table: CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPEPAYMENT_AMOUNT 8908090 10-JUN-2003 BASIC 859.00
89453485 8549038 15-FEB-2003 INTEREST 596.00 85490345 5489304 20-MAR-2003 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 SUM(payment_amount) FROM payment WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
Correct
Correct
46. You need to compute the total salary amount for all employees in department 10. Which group function will you use? Mark for Review (1) Points
MAX
SUM (*)
VARIANCE
COUNT
Incorrect
The COUNT function can be used to find the maximum value in each column.
The COUNT function can be used to determine the number of unique, non-null values in a column.
Incorrect
48. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) SALARY NUMBER(7,2) DEPARTMENT_ID NUMBER(9) You need to display the number of employees whose salary is greater than $50,000? Which SELECT would you use?
SELECT COUNT(*) FROM employees WHERE salary > 50000 GROUP BY employee_id, last_name, first_name, salary, department_id;
Incorrect
49. Which SELECT statement will calculate the number of rows in the PRODUCTS table? Mark for Review (1) Points
SELECT COUNT(products);
Incorrect
Group functions can avoid computations involving duplicate values by including Mark for Review
NULL
DISTINCT (*)
SELECT
UNLIKE
Incorrect
Previous
Page 5 of 5
Summary