Select Statement  «Prev 

SQL Select - Quiz

Each question is worth one point. Select the best answer or answers for each question.

 
1. Given the following columns from a table named MyTable:
MyLastName MyFirstName MyAddress MyCity MyState MyZipCode
If you want to sort the results based on MyLastName, what statement would you use if you wanted to see all rows (including duplicates) in the results?
  A.
SELECT * FROM MyTable 
GROUP BY MyLastName
  B.
						 
SELECT * FROM MyTable 
SORTED BY MyLastName
  C.
SELECT * FROM MyTable 
ORDER BY MyLastName
  D.
SELECT * FROM MyTable 
GROUP BY MyLastName, DUPLICATES="Y"

2. Using the table from Question 1, which statement below could you use to select only the unique states that are in the table?
  A. SELECT MyState FROM MyTable GROUP BY MyState
  B. SELECT * FROM MyTable SORTED BY MyState
  C. SELECT * FROM MyTable ORDER BY MyState
  D. SELECT * FROM MyTable GROUP BY MyState, DUPLICATES="Y"

3. What's wrong with the following statement?
SELECT * FROM MyTable GROUP BY MyState
  A. Nothing is wrong with this statement
  B. An ORDER BY clause should be used
  C. You must indicate all the columns from the table in the GROUP BY clause
  D. The "*" operator cannot be used in GROUP BY statements


4. If you have a table containing sales information for an organization and want to query that table to retrieve sales value totals for each district, but not the detail line items, what type of statement would you use?
  A. A sub-SELECT to limit the results by district
  B. A GROUP BY to summarize the results
  C. A SELECT statement with the DISTINCT keyword to filter detail lines
  D. An ORDER BY clause to group and summarize results

5. If you want to show the grades from a Grades table only for those students with a specific grade level, maintained in a StudentInfo table, what type of statement would you use?
  A. A sub-SELECT statement to pull the related information between the two tables
  B. A GROUP BY to relate the tables and summarize the grades
  C. A SELECT statement with the DISTINCT keyword to summarize grade information
  D. An ORDER BY clause to relate the results

6. If you want to query a sales table to find out which customers have ordered, and only want a listing of customers represented in the table and no details about the orders or any information about duplicates, which statement or clause is most appropriate?
  A. A sub-SELECT to select the unique rows for the query
  B. A GROUP BY to summarize the customer order information, then pull the order information
  C. A SELECT statement with the DISTINCT keyword to filter the table's duplicate results
  D. An ORDER BY clause to sort and filter the results

7. Which of the following is not true when using an EQUALS clause?
  A. The sub-SELECT statement needs to return only one result
  B. You cannot use a WHERE clause with the subSELECT statement if you use the EQUALS clause
  C. The EQUALS clause can be used for both SELECT and subSELECT statements
  D. You use the "=" symbol rather than the word "EQUALS" when running the query


Your Score: 0