Section 3 Quiz
Which of the following is
earliest in the rules of precedence?
Arithmetic
operator (*)
Concatenation
operator
Logical
condition
Comparison
condition
Which of the following
statements best describes the rules of precedence when using SQL?
The
order in which the columns are displayed
The
order in which the expressions are sorted
The
order in which the operators are returned
The
order in which the expressions are evaluated and calculated (*)
All of
the above
From left to right, what is the
correct order of Precedence?
NOT,
AND, OR, Arithmetic
Arithmetic,
Concatenation, Comparison, OR (*)
Arithmetic,
NOT, Concatenation, Logical
Arithmetic,
NOT, Logical, Comparison
The ORDER BY clause always
comes last. True or False?
True
(*)
False
Which of the following are TRUE
regarding the logical AND operator?
TRUE
AND FALSE return TRUE
FALSE
AND TRUE return NULL
TRUE
AND TRUE return FALSE
TRUE
AND FALSE return FALSE (*)
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 numerically only.
The
results are sorted alphabetically only.
The
results are sorted alphabetically and then numerically. (*)
The
results are sorted numerically and then alphabetically.
Evaluate this SELECT statement:
SELECT employee_id, last_name, first_name, salary 'Yearly
Salary'
FROM employees
WHERE salary IS NOT NULL
ORDER BY last_name, 3;
Which clause contains an error?
ORDER
BY last_name, 3;
SELECT
employee_id, last_name, first_name, salary 'Yearly Salary' (*)
WHERE
salary IS NOT NULL
FROM
employees
Evaluate this SELECT statement:
SELECT last_name, first_name, email
FROM employees
ORDER BY email;
If the EMAIL column contains null values, which statement is
true?
Null
email values will be displayed last in the result. (*)
Null
email values will not be displayed in the result.
Null
email values will be displayed first in the result.
The
result will not be sorted.
What clause must you place in a
SQL statement to have your results sorted from highest to lowest salary?
ORDER
salary BY DESC
None,
the database always sorts from highest to lowest on the salary column.
ORDER
BY salary ASC
ORDER
BY salary DESC (*)
You query the database with this
SQL statement:
SELECT price
FROM products
WHERE price IN(1, 25, 50, 250)
AND (price BETWEEN 25 AND 40 OR price > 50);
Which two values could the statement return? (Choose two.)
10
1
50
250 (*)
25 (*)
The conversion function TO_CHAR is a single row function.
True or False?
True
(*)
False
Will the following statement
return one row?
SELECT MAX(salary), MIN(Salary), AVG(SALARY)
FROM employees;
No, it
is illegal. You cannot use more than one multi-row function in a SELECT
statement.
Yes, it
will return the highest salary from each employee.
Yes, it
will return the highest salary, the lowest salary, and the average salary from
all employees. (*)
Yes, it
will return the average salary from the employees table.
The PLAYERS table contains these
columns:
PLAYERS TABLE:
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
SALARY NUMBER(8,2)
TEAM_ID NUMBER(4)
MANAGER_ID NUMBER(9)
POSITION_ID NUMBER(4)
You want to display all players' names with position 6900 or
greater.
You want the players names to be displayed alphabetically by
last name and then by first name.
Which statement should you use to achieve the required
results?
SELECT
last_name, first_name
FROM players
WHERE position_id > 6900
ORDER BY last_name, first_name;
SELECT
last_name, first_name
FROM players
WHERE position_id >= 6900
ORDER BY last_name DESC, first_name;
SELECT
last_name, first_name
FROM players
WHERE position_id <= 6900
ORDER BY last_name, first_name;
SELECT
last_name, first_name
FROM players
WHERE position_id >= 6900
ORDER BY last_name, first_name;
(*)
Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name,
m.manager_id
FROM employees e, employees m
ORDER BY e.last_name, e.first_name
WHERE e.employee_id = m.manager_id;
This statement fails when executed. Which change will
correct the problem?
Include
a HAVING clause.
Reorder
the clauses in the query. (*)
Remove
the table aliases in the ORDER BY clause.
Remove
the table aliases in the WHERE clause.
The PLAYERS table contains these
columns:
PLAYERS TABLE:
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
SALARY NUMBER(8,2)
TEAM_ID NUMBER(4)
MANAGER_ID NUMBER(9)
POSITION_ID NUMBER(4)
You must display the player name, team id, and salary for
players whose salary is in the range from 25000 through 100000 and whose team
id is in the range of 1200 through 1500. The results must be sorted by team id
from lowest to highest and then further sorted by salary from highest to
lowest. Which statement should you use to display the desired result?
SELECT
last_name, first_name, team_id, salary
FROM players
WHERE salary BETWEEN 24999.99 AND 100000.01
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id DESC, salary DESC;
SELECT
last_name, first_name, team_id, salary
FROM players
WHERE salary BETWEEN 25000 AND 100000
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id, salary DESC;
(*)
SELECT
last_name, first_name, team_id, salary
FROM players
WHERE salary > 24999.99 AND salary < 100000
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id ASC, salary DESC;
SELECT
last_name, first_name, team_id, salary
FROM players
WHERE (salary > 25000 OR salary < 100000)
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id, salary;
No comments:
Post a Comment