Aggregate Functions In MySQL Flashcards

1
Q

What are aggregate functions in MySQL used for?

A

To perform calculations on a set of values and return a single value as a result

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

What does the COUNT() function do?

A

Counts the number of rows that meet a specified condition

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

What is the syntax for the COUNT() function?

A

COUNT(column_name) or COUNT(*)

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

Provide an example of using COUNT() in SQL.

A

SELECT COUNT(*) FROM customers

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

What does the SUM() function calculate?

A

The sum of values in a specified column

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

What is the syntax for the SUM() function?

A

SUM(column_name)

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

Provide an example of using SUM() in SQL.

A

SELECT SUM(amount) FROM orders

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

What does the AVG() function calculate?

A

The average value of a specified column

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

What is the syntax for the AVG() function?

A

AVG(column_name)

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

Provide an example of using AVG() in SQL.

A

SELECT AVG(price) FROM products

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

What does the MIN() function return?

A

The minimum value of a specified column

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

What is the syntax for the MIN() function?

A

MIN(column_name)

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

Provide an example of using MIN() in SQL.

A

SELECT MIN(order_date) FROM orders

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

What does the MAX() function return?

A

The maximum value of a specified column

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

What is the syntax for the MAX() function?

A

MAX(column_name)

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

Provide an example of using MAX() in SQL.

A

SELECT MAX(salary) FROM employees

17
Q

What is the purpose of the GROUP BY clause?

A

To group the results based on one or more columns

18
Q

What is the syntax for using aggregate functions with GROUP BY?

A

SELECT column_name, aggregate_function(column_name) FROM table_name GROUP BY column_name

19
Q

Provide an example of using GROUP BY with COUNT() in SQL.

A

SELECT country, COUNT(*) FROM customers GROUP BY country

20
Q

Do aggregate functions ignore NULL values?

A

Yes, except for COUNT(*)

21
Q

What keyword can be used within COUNT() to count distinct values?

A

DISTINCT

22
Q

What are some additional aggregate functions mentioned?

A
  • GROUP_CONCAT()
  • STDDEV()
  • VARIANCE()
23
Q

Fill in the blank: Aggregate functions are often used in combination with other clauses like _______ and _______ to filter results.

A

[WHERE, HAVING]