Programming Mid
Programming Mid
SELECT LENGTH(email)
FROM employee;
The number of characters for each value in the EMAIL column in the
employees table. (*)
Correct
2. 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
3. Which SQL function is used to return the position where a specific character
string begins within a larger character string? Mark for Review
(1) Points
CONCAT
INSTR (*)
LENGTH
SUBSTR
Correct
4. You need to display the number of characters in each customer's last name.
Which function should you use? Mark for Review
(1) Points
LENGTH (*)
LPAD
COUNT
SUBSTR
Correct
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, left-padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where
expected."
Correct
7. Which three statements about functions are true? (Choose three.) Mark for
Review
(1) Points
The SYSDATE function returns the Oracle Server date and time. (*)
The ROUND number function rounds a value to a specified decimal place or the
nearest whole number. (*)
The CONCAT function can only be used on character strings, not on numbers.
Section 1 Lesson 2
(Answer all questions in this section)
8. You issue this SQL statement:
1200
1282
1282.25
1300 (*)
Correct
IN (*)
LIKE
BETWEEN...IN...
IS NULL
Correct
10. Evaluate this function: MOD (25, 2) Which value is returned? Mark for
Review
(1) Points
1 (*)
25
0
Correct
Section 1 Lesson 3
(Answer all questions in this section)
11. Which SELECT statement will return a numeric value? Mark for Review
(1) Points
SELECT SYSDATE - 7
FROM employee;
SELECT SYSDATE + 30
FROM dual;
13. Which of the following SQL statements will correctly display the last name
and the number of weeks employed for all employees in department 90? Mark
for Review
(1) Points
Correct
14. 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 (*)
15. You want to create a report that displays all orders and their amounts that
were placed during the month of January. You want the orders with the highest
amounts to appear first. Which query should you issue? Mark for Review
(1) Points
Correct
Section 2 Lesson 1
(Answer all questions in this section)
16. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
HIRE_DATE DATE
17. You have been asked to create a report that lists all customers who have
placed orders of at least $2,500. The report's date should be displayed in the
Day, Date Month, Year format (For example, Tuesday, 13 April, 2004 ). Which
statement should you issue? Mark for Review
(1) Points
18. 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
Correct
19. Which two statements concerning SQL functions are true? (Choose two.)
Mark for Review
(1) Points
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
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees. Which script
should you use to display the salaries in format: "$45,000.00"?
Mark for Review
(1) Points
Correct
Section 2 Lesson 1
(Answer all questions in this section)
21. Which statement concerning single row functions is true? Mark for Review
(1) Points
Single row functions can accept only one argument, but can return multiple
values.
Section 2 Lesson 2
(Answer all questions in this section)
22. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace
null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace
null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null
values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace
null values.
Correct
24. 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 (*)
Correct
Section 3 Lesson 2
(Answer all questions in this section)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total
sales?
Correct
26. You have been asked to create a report that lists all corporate customers
and all orders that they have placed. The customers should be listed
alphabetically beginning with the letter 'A', and their corresponding order totals
should be sorted from the highest amount to the lowest amount.
Which of the following statements should you issue? Mark for Review
(1) Points
Correct
27. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all
possibilities
All rows that do not match in the WHERE clause are displayed
Correct
a self-join
an outer join
an equijoin
30. Your have two tables named EMPLOYEES and SALES. You want to identify
the sales representatives who have generated at least $100,000 in revenue.
Which query should you issue? Mark for Review
(1) Points
Section 3 Lesson 4
(Answer all questions in this section)
the join between the player table and the team table on TEAM_ID
the join between the player table and the team table on MANAGER_ID
the join between the player table and the team table on PLAYER_ID
natural join
self-join
equijoin
(+) (*)
Correct
Section 4 Lesson 2
(Answer all questions in this section)
34. You need to join two tables that have two columns with the same name and
compatible data types. Which type of join would you create to join the tables on
both of the columns? Mark for Review
(1) Points
Cross join
Outer join
Self-join
Correct
35. A join between tables where the result set includes matching values from
both tables but does NOT return any unmatched rows could be called which of
the following? (Choose three) Mark for Review
(1) Points
Equijoin (*)
Self join (*)
Nonequijoin
36. 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 (*)
Correct
Section 4 Lesson 3
(Answer all questions in this section)
A HAVING clause
38. 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.
39. The primary advantage of using JOIN ON is: Mark for Review
(1) Points
The join happens automatically based on matching column names and data
types
40. 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 4 Lesson 4
(Answer all questions in this section)
41. Which two sets of join keywords create a join that will include unmatched
rows from the first table specified in the SELECT statement? Mark for Review
(1) Points
42. Which query represents the correct syntax for a left outer join? Mark for
Review
(1) Points
an inner join
Correct
Section 5 Lesson 1
(Answer all questions in this section)
The hire dates in the EMPLOYEE table that contain NULL values.
Correct
45. 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.
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.
47. 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
Section 5 Lesson 2
(Answer all questions in this section)
48. You need to calculate the average salary of employees in each department.
Which group function will you use? Mark for Review
(1) Points
AVG (*)
MEAN
MEDIAN
AVERAGE
49. Which aggregate function can be used on a column of the DATE data type?
Mark for Review
(1) Points
AVG
MAX (*)
STDDEV
SUM
Correct
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
Section 5 Lesson 2
(Answer all questions in this section)
51. 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
Correct
Which three functions could be used with the HIRE_DATE, LAST_NAME, or SALARY
columns? (Choose three.)
Mark for Review
(1) Points
MAX (*)
SUM
AVG
MIN (*)
COUNT (*)
Which two clauses represent valid uses of aggregate functions for this table?
Mark for Review
(1) Points
FROM MAX(order_dt)
SELECT SUM(order_dt)
55. Which group function would you use to display the highest salary value in
the EMPLOYEE table? Mark for Review
(1) Points
AVG
COUNT
MAX (*)
MIN
Correct
Section 5 Lesson 3
(Answer all questions in this section)
56. Evaluate this SELECT statement:
SELECT COUNT(*)
FROM products;
Correct
NULL
DISTINCT (*)
SELECT
UNLIKE
Correct
58. Which SELECT statement will calculate the number of rows in the
PRODUCTS table? Mark for Review
(1) Points
SELECT COUNT(products);
Correct
You need to display the number of employees whose salary is greater than
$50,000? Which SELECT would you use?
Mark for Review
(1) Points
Correct
Section 6 Lesson 1
(Answer all questions in this section)
60. What is the correct order of clauses in a SELECT statement? Mark for
Review
(1) Points
SELECT
FROM
WHERE
ORDER 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
Section 6 Lesson 1
(Answer all questions in this section)
Correct
Which SELECT statement could you use to display the number of times each
customer made a payment between January 1, 2003 and June 30, 2003 ?
Mark for Review
(1) Points
SELECT 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;
63. 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
Correct
The ORDER BY clause must specify a column name in the EMPLOYEE table.
Correct
Correct
67. 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 use should a WHERE clause. (*)
You must use the HAVING clause with the GROUP BY clause.
Section 6 Lesson 2
(Answer all questions in this section)
68. Which operator can be used with a multiple-row subquery? Mark for Review
(1) Points
IN (*)
<>
LIKE
Correct
69. 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 product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
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 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. (*)
Section 6 Lesson 2
(Answer all questions in this section)
71. Which operator can be used with subqueries that return only one row?
Mark for Review
(1) Points
LIKE (*)
ANY
ALL
IN
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
Section 6 Lesson 3
(Answer all questions in this section)
73. Which statement about the <> operator is true? Mark for Review
(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. (*)
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
75. 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
LIKE
BETWEEN...AND...
Correct
ALL
ANY
= (*)
>
Correct
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
79. Which of the following best describes the meaning of the ANY operator?
Mark for Review
(1) Points
80. What would happen if you attempted to use a single-row operator with a
multiple-row subquery? Mark for Review
(1) Points
Section 6 Lesson 4
(Answer all questions in this section)
MANUFACTURERS:
ID NUMBER
PK NAME VARCHAR2(30)
LOCATION VARCHAR2(20)
SELECT parts_name
FROM
(SELECT AVG(cost)
FROM manufacturers)
WHERE cost > AVG(cost);
82. You are looking for Executive information using a subquery. What will the
following SQL statement display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
(SELECT department_id
FROM departments
WHERE department_name = 'Executive');
Mark for Review
(1) Points
The department ID, department name and last name for every employee in the
Executive department.
The department ID, last name, department name for every Executive in the
employees table.
The department ID, last name, job ID from departments for Executive
employees.
The department ID, last name, job ID for every employee in the Executive
department. (*)
Correct
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
84. You need to display all the products that cost more than the maximum cost
of every product produced in Japan. Which multiple-row comparison operator
could you use? Mark for Review
(1) Points
>ANY (*)
NOT=ALL
IN
>IN
85. Which statement about the ANY operator when used with a multiple-row
subquery is true? Mark for Review
(1) Points
The ANY operator compares every value returned by the subquery. (*)
The ANY operator can be used with the LIKE and IN operators.
All the rows in the PLAYER table would be returned by the outer query.
Correct
Section 7 Lesson 1
(Answer all questions in this section)
All full-time students are inserted into the FT_STUDENTS table. (*)
An error occurs because the INSERT statement does NOT contain a VALUES
clause.
88. Which statement about the VALUES clause of an INSERT statement is true?
Mark for Review
(1) Points
If no column list is specified, then the values must be in the order the columns
are specified in the table. (*)
Character, date, and numeric data must be enclosed within single quotes in
the VALUES clause.
To specify a null value in the VALUES clause, use an empty string (' ').
an ON clause
a SET clause
a subquery (*)
a function
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
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.
91. 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:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
SET cooper = 'lname'
WHERE lname = 'roper';
Correct
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 employee
SET salary = SELECT salary
FROM employee
WHERE emp_id = 89898;
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898);
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898)
WHERE dept = 10;
(*)
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept
= 10);
Correct
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
Correct
94. 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:
ID_NUM NUMBER(5) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME 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
95. 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? Mark for Review
(1) Points
the ON clause
Correct
96. 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;
97. 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? Mark for Review
(1) Points
98. When the WHERE clause is missing in a DELETE statement, what is the
result? Mark for Review
(1) Points
Correct
99. What keyword in an UPDATE statement speficies the columns you want to
change? Mark for Review
(1) Points
SELECT
WHERE
SET (*)
HAVING
Correct
100. You need to update both the DEPARTMENT_ID and LOCATION_ID columns
in the EMPLOYEE table using one UPDATE statement. Which clause should you
include in the UPDATE statement to update multiple columns? Mark for Review
(1) Points