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;
2
Q
Sum
A
SELECT SUM(no_seats) FROM rooms; (δεν μπαινει αστερακι γιατι πρεπει να προσθεσει αριθμους)
SELECT SUM(no_seats) FROM rooms WHERE id > 1;
3
Q
Max and Min
A
SELECT MAX(length_min) FROM films; SELECT MIN(length_min) FROM films;
4
Q
AVG
A
SELECT AVG(length_min) FROM films;
SELECT AVG(length_min) FROM films WHERE length_min > 120;