Database Programming with SQL Section 3 Quiz

Section 3 Quiz
(Answer all questions in this section)

1. Evaluate this SQL statement:
SELECT product_id, product_name, price
FROM products
ORDER BY product_name, price;

What occurs when the statement is executed?


The results are sorted alphabetically and then numerically. (*)

The results are sorted numerically only.


The results are sorted numerically and then alphabetically.


The results are sorted alphabetically only.


2. Evaluate this SELECT statement:
SELECT *
FROM employees
WHERE department_id = 34
OR department_id = 45
OR department_id = 67;

Which operator is the equivalent of the OR conditions used in this SELECT statement?

BETWEEN AND ...

IN (*)

AND

LIKE


3. Which columns can be added to the ORDER BY clause in the following SELECT statement? (Choose Three)
SELECT first_name, last_name, salary, hire_date
FROM employees
WHERE department_id = 50
ORDER BY ?????;

Any column in the EMPLOYEES table, any expression in the SELECT list or any ALIAS in the SELECT list (*)

All columns in the EMPLOYEES table (*)
The table name, EMPLOYEES, which would then automatically sort by all columns in the table
All the columns in the database

last_name, first_name (*)



4. Evaluate this SELECT statement:
SELECT first_name, last_name, email
FROM employees
ORDER BY last_name;

Which statement is true?


The rows will be sorted alphabetically by the LAST_NAME values. (*)

The rows will be sorted alphabetically by the FIRST_NAME and then the LAST_NAME values

The rows will not be sorted.


The rows will be sorted in reverse alphabetical order by the LAST_NAME values.



5. A column alias can be specified in an ORDER BY Clause. True or False?


True (*)


False



Section 3 Quiz
(Answer all questions in this section)

6. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9) PK
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
Compare these two SQL statements:

1.
SELECT DISTINCT department_id DEPT, last_name, first_name
FROM employees
ORDER BY department_id;

2.
SELECT department_id DEPT, last_name, first_name
FROM employees
ORDER BY DEPT;

How will the results differ?


There is no difference in the result between the two statements.


One of the statements will eliminate all duplicate DEPARTMENT_ID values.


One of the statements will return a syntax error.


The statements will sort on different column values. (*)




7. The following statement represents a multi-row function. True or False?
SELECT MAX(salary)
FROM employees


True (*)


False




8. The conversion function TO_CHAR is a single row function. True or False?


True (*)

False

9. The following statement represents a multi-row function. True or False?
SELECT UPPER(last_name)
FROM employees;


True

False (*)


10. The function COUNT is a single row function. True or False?


True

False (*)


Section 3 Quiz
(Answer all questions in this section)

11. Which of the following is earliest in the rules of precedence?

Concatenation operator

Arithmetic operator (*)

Comparison condition

Logical condition


12. Which statement about the default sort order is true?

Character values are displayed in reverse alphabetical order.

The lowest numeric values are displayed last.


The earliest date values are displayed first. (*)

Null values are displayed first.

13. Which statement about the logical operators is true?


The order of operator precedence is NOT, OR, and AND.

The order of operator precedence is AND, NOT, and OR.

The order of operator precedence is NOT, AND, and OR. (*)

The order of operator precedence is AND, OR, and NOT.



14. What will be the results of the following selection?
SELECT *
FROM employees
WHERE last_name NOT LIKE 'A%' AND last_name NOT LIKE 'B%'


No rows will be returned. There is a syntax error


All last names that begin with A or B


All last names that do not begin with A or B (*)


All rows will be returned

15. The ORDER BY clause always comes last. True or False?

True (*)

False

Comments