Post midterm SQL Flashcards
How are alias that include whitespace referenced outside of the SELECT statement?
in brackets: [alias name].
DATEDIFF arguments in order:
DATEDIFF(1,2,3)
1: time metric.
2: date1, subtracted from date2
3: date2.
What is the use and data type output from MONTH(), YEAR(), or DAY()?
Use: isolate a time metric in a date data type.
Output: integer.
What is the Syntax for OFFSET & FETCH?
OFFSET ?? ROWS
FETCH NEXT ?? ROWS ONLY;
How do you filter for NULL or NON NULL values in the WHERE clause (Syntax)?
“attribute IS NULL” or “attribute IS NOT NULL.”
The 5 aggregate functions can be sorted into two categories based on output. What are they and what are their possible outputs?
COUNT(), AVG(), and SUM() create numeric outputs. They can be decimal or integer.
MIN() and MAX() can have string, numeric, or date outputs.
What two ways can you use COUNT() to find the number of rows in a table?
COUNT(PK_attribute) or COUNT(*).
What does DISTINCT do?
Selects unique values from the first attribute in the SELECT statement.
What stipulate does the use of GROUP BY put on the SELECT statement?
All SELECT statement attributes must be either in the GROUP BY clause or an aggregate function.
You can assign DESC order to each attribute in ORDER BY clause. True or False?
True.
Alphabetical Ascending
A to Z.
Alphabetical Descending
Z to A.
Date Ascending
Oldest date to newest date.
2003 to 2024.
Date Descending
Newest date to oldest date.
2024 to 2003.
CONCAT(IDNum, State) is ordered as a number because the values start with integers. True or false?
False. They are treated as alphanumeric values.