11. What is the result of the following query: SELECT (Current_Date – RescueDate) FROM PetRescue

  • Returns today’s date.
  • Returns how long it has been since each rescue.
  • Returns the rescue date for each rescue.
  • Returns the current date and rescue date columns.

12. Which of the following queries will return the employees who earn less than the average salary?

  • SELECT * FROM Employees WHERE Salary < AVG(Salary)
  • SELECT * FROM Employees WHERE Salary < (SELECT AVG(Salary))
  • SELECT AVG(Salary) FROM Employees WHERE Salary < AVG(Salary)
  • SELECT * FROM Employees WHERE Salary < (SELECT AVG(Salary) FROM Employees);

13. What are the three ways to work with multiple tables in the same query?

  • Sub-queries, Implicit joins, JOIN operators
  • Sub-queries, APPEND, JOIN operators
  • Built-in functions, implicit joins, JOIN operators
  • Sub-queries, Implicit joins, normalization.

Graded Quiz: Functions, Sub-Queries, Multiple Tables

14. Which of the following queries will return the data for employees who belong to the department with the highest value of department ID.

  • SELECT * FROM EMPLOYEES WHERE DEPT_ID_DEP =

    MAX ( SELECT DEPT_ID_DEP FROM DEPARTMENTS )

  • SELECT * FROM EMPLOYEES WHERE DEP_ID =

    ( SELECT MAX(DEPT_ID_DEP) FROM DEPARTMENTS )

  • SELECT * FROM EMPLOYEES WHERE DEP_ID = MAX(DEP_ID)
  • SELECT * FROM EMPLOYEES WHERE DEP_ID =

    ( SELECT DEPT_ID_DEP FROM DEPARTMENTS WHERE DEPT_ID_DEP IS MAX )

15. A DEPARTMENTS table contains DEP_NAME, and DEPT_ID_DEP columns and an EMPLOYEES table contains columns called F_NAME and DEP_ID. We want to retrieve the Department Name for each Employee. Which of the following queries will correctly accomplish this?

  • SELECT F_NAME, DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE E.DEPT_ID_DEP = D.DEP_ID
  • SELECT D.F_NAME, E.DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE DEPT_ID_DEP = DEP_ID
  • SELECT F_NAME, DEP_NAME FROM EMPLOYEES, DEPARTMENTS WHERE DEPT_ID_DEP = DEP_ID
  • SELECT E.F_NAME, D.DEP_NAME FROM EMPLOYEES, DEPARTMENTS

16. You are writing a query that will give you the total cost to the Pet Rescue organization of rescuing animals. The cost of each rescue is stored in the Cost column. You want the result column to be called “Total_Cost”. Which of the following SQL queries is correct?

  • SELECT SUM(Cost) FROM PetRescue
  • SELECT SUM(Cost) AS Total_Cost FROM PetRescue
  • SELECT SUM(Total_Cost) From PetRescue
  • SELECT Total_Cost FROM PetRescue

Leave a Reply