Database Programming Section 3 Quiz

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Database Programming Section 3 Quiz

Section 3 Quiz
(Answer all questions in this section)

1. 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? Mark for Review
(1) Points

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 > 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;

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;(*)
2. The following statement represents a multi-row function.
True or False?
SELECT MAX(salary)
FROM employees Mark for Review
(1) Points

True (*)

False

3. 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? Mark for Review
(1) Points
Remove the table aliases in the WHERE clause.

Include a HAVING clause.

Remove the table aliases in the ORDER BY clause.

Reorder the clauses in the query. (*)

4. The function COUNT is a single row function. True or


False? Mark for Review
(1) Points

True

False (*)
5. Will the following statement return one row?
SELECT MAX(salary), MIN(Salary), AVG(SALARY)
FROM employees; Mark for Review
(1) Points

No, it is illegal. You cannot use more than one multi-row function in a
SELECT statement.

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.

Yes, it will return the highest salary from each employee.


(Answer all questions in this section)

6. Which of the following are examples of logical operators


that might be used in a WHERE clause. (Choose Two) Mark for
Review
(1) Points

(Choose all correct answers)

AND, OR (*)

< >, =, <=, >=, <>

NOT (*)

LIKES

All of the above


7. Which of the following would be returned by this SQL
statement:
SELECT First_name, last_name, department_id
FROM employees
WHERE department_id IN(50,80)
AND first_name LIKE ' C% '
OR last_name LIKE ' %s% ' Mark for Review
(1) Points

FIRST_NAME LAST_NAME DEPARTMENT_ID


Shelly Higgins 110

FIRST_NAME LAST_NAME DEPARTMENT_ID


Curtis Davies 50

FIRST_NAME LAST_NAME DEPARTMENT_ID


Randall Matos 50
FIRST_NAME LAST_NAME DEPARTMENT_ID
Michael Hartstein 20

All of the above (*)

8. Which symbol in the WHERE clause means "Not Equal


To"? (Choose Two) Mark for Review
(1) Points

(Choose all correct answers)

<> (*)

=+
NOT IN (..) (*)

><

9. Which statement about the logical operators is true?


Mark for Review
(1) Points

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 NOT, OR, and AND.

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


10. Which comparison condition means "Less Than or Equal
To"? Mark for Review
(1) Points

"=)"

">="

"<=" (*)

"+<"

(Answer all questions in this section)

11. Evaluate this SELECT statement:


SELECT last_name, first_name, salary
FROM employees;
How will the results of this query be sorted? Mark for Review
(1) Points

The results will be sorted ascending by LAST_NAME, FIRST_NAME,


and SALARY.

The results will be sorted ascending by the LAST_NAME column only.

The database will display the rows in whatever order it finds it in the
database, so no particular order. (*)

The results will be sorted ascending by LAST_NAME and


FIRST_NAME only.

12. What value will the following SQL statement return?


SELECT employee_id
FROM employees
WHERE employee_id BETWEEN 100 AND 150
OR employee_id IN(119, 175, 205)
AND (employee_id BETWEEN 150 AND 200); Mark for Review
(1) Points

100, 101, 102, 103, 104, 107, 124, 141, 142, 143, 144, 149 (*)

200, 201, 202, 203, 204, 205, 206

No rows will be returned

19

13. Evaluate this SQL statement:


SELECT product_id, product_name, price
FROM products
ORDER BY product_name, price;
What occurs when the statement is executed? Mark for Review
(1) Points

The results are sorted numerically only.

The results are sorted numerically and then alphabetically.

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

The results are sorted alphabetically only.

14. Which SELECT statement should you use to limit the


display of product information to those products with a price of less
than 50? Mark for Review
(1) Points

SELECT product_id, product_name


FROM products
HAVING price < 50;

SELECT product_id, product_name


FROM products
WHERE price < 50;
(*)

SELECT product_id, product_name


FROM products
WHERE price <= 50;

SELECT product_id, product_name


FROM products
WHERE price < 50.00
GROUP BY price;

SELECT product_id, product_name


FROM products
GROUP BY price < 50;
15. 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? Mark for Review
(1) Points

ORDER BY last_name, 3;

WHERE salary IS NOT NULL

FROM employees

SELECT employee_id, last_name, first_name, salary 'Yearly Salary'


(*)

You might also like