L24 - SQL 2 Flashcards

1
Q

What are SQL ISO standard functions?

A
  1. COUNT - number of vales in specified column
  2. SUM - Sum of values in specified column
  3. AVG - Average of values in specified column
  4. MIN - Lowest Value in specified column
  5. MAX - highest value in specfied column
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you use COUNT and SUM

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you use MIN, MAX, AVG?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you use GROUP BY?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you utilise a simple join?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly