L24 - SQL 2 Flashcards
1
Q
What are SQL ISO standard functions?
A
- COUNT - number of vales in specified column
- SUM - Sum of values in specified column
- AVG - Average of values in specified column
- MIN - Lowest Value in specified column
- MAX - highest value in specfied column
2
Q
What is general SQL aggregate utility?
A
- Operates on single column
- Return single value
- COUNT, MIN, MAX - numeric/non-numeric
- SUM, AVG - numeric
- All (Excluding COUNT) work via
- Eliminate null
- Work on non-null values
3
Q
How does the count function work?
A
- COUNT(*) counts all rows
- Regardless of Null
- DISTINCT used to eliminate any duplicated
- No effect with MIN/MAX
- May have some effect with SUM/AVG
4
Q
How do you use COUNT and SUM
A
5
Q
How do you use MIN, MAX, AVG?
A
6
Q
How can you group results?
A
- GROUP BY
- Used to get sub totals
- Closely integrated with SELECT
- SELECT list must be single-valued per group
- SELECT clause may only have:
- Column names
- Aggregate functions
- Constants
- Or a combination of the three
7
Q
How do you use GROUP BY?
A
8
Q
What is a restricted returned group?
A
- HAVING to be paired with GROUP BY
- Restrict groups that appear in final result table
- Adds filter groups
- Column names in the HAVING clause:
- Must also appear in the GROUP BY list
- Contained within an aggregate function
9
Q
How do you utilise a simple join?
A