What is GroupBy Clause
Group by Clause Insights
Group BY vs. Sorting
SQL Select- Quiz
SQL Subquery Statements
Understand SQL Views
How views are called?
Steps to Create View
Updating Table Row Views
Updating Table with View
SQL Views - Quiz
Key Sql Functions
Date Function - Exercise
SQL Function Conclusion
SQL Select - Quiz
Each question is worth one point. Select the best answer or answers for each question.
Given the following columns from a table named MyTable:
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?
SELECT * FROM MyTable GROUP BY MyLastName
SELECT * FROM MyTable SORTED BY MyLastName
SELECT * FROM MyTable ORDER BY MyLastName
SELECT * FROM MyTable GROUP BY MyLastName, DUPLICATES="Y"
Using the table from Question 1, which statement below could you use to select only the unique states that are in the table?
SELECT MyState FROM MyTable GROUP BY MyState
SELECT * FROM MyTable SORTED BY MyState
SELECT * FROM MyTable ORDER BY MyState
SELECT * FROM MyTable GROUP BY MyState, DUPLICATES="Y"
What's wrong with the following statement?
SELECT * FROM MyTable GROUP BY MyState
Nothing is wrong with this statement
An ORDER BY clause should be used
You must indicate all the columns from the table in the GROUP BY clause
The "*" operator cannot be used in GROUP BY statements
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 sub-SELECT to limit the results by district
A GROUP BY to summarize the results
A SELECT statement with the DISTINCT keyword to filter detail lines
An ORDER BY clause to group and summarize results
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 sub-SELECT statement to pull the related information between the two tables
A GROUP BY to relate the tables and summarize the grades
A SELECT statement with the DISTINCT keyword to summarize grade information
An ORDER BY clause to relate the results
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 sub-SELECT to select the unique rows for the query
A GROUP BY to summarize the customer order information, then pull the order information
A SELECT statement with the DISTINCT keyword to filter the table's duplicate results
An ORDER BY clause to sort and filter the results
Which of the following is not true when using an EQUALS clause?
The sub-SELECT statement needs to return only one result
You cannot use a WHERE clause with the subSELECT statement if you use the EQUALS clause
The EQUALS clause can be used for both SELECT and subSELECT statements
You use the "=" symbol rather than the word "EQUALS" when running the query
Your Score: 0