Aggregate functions Flashcards

1
Q

Count

A

SELECT COUNT(*) FROM customers;

SELECT COUNT(last_name) FROM customers;

βαζουμε και where clause
SELECT COUNT(*) FROM customers
WHERE last_name = 'Smith';
 SELECT COUNT(*) FROM customers
WHERE first_name  IS NULL;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Sum

A

SELECT SUM(no_seats) FROM rooms; (δεν μπαινει αστερακι γιατι πρεπει να προσθεσει αριθμους)

SELECT SUM(no_seats) FROM rooms
WHERE id > 1;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Max and Min

A
SELECT MAX(length_min) FROM films;
SELECT MIN(length_min) FROM films;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

AVG

A

SELECT AVG(length_min) FROM films;

SELECT AVG(length_min) FROM films
WHERE length_min > 120;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly