Chapter 2, Level 1: Aggregate Functions Flashcards

1
Q

The … function calculates the smallest value for the selected column.

A

min

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

Which ‘aggregate function’ statement will return the numerical sum of all values in one column or more?

A
SELECT sum(column_name)
FROM table_name;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which ‘aggregate function’ statement will return the total number of rows in a table, except for those with a null value?

A
SELECT count(column_name)
FROM table_name;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which functions (also known as aggregate functions) only work if the columns contain numbers?

A

min
max
sum
avg

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

Which ‘aggregate function’ statement will return the numerical average of all values in one column or more?

A
SELECT avg(column_name)
FROM table_name;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which ‘aggregate function’ statement will return the total number of rows in a table?

A
SELECT count(*)
FROM table_name;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or false:

When using the ‘count(*)’ function statement, rows with ‘null’ values will be returned as well.

A

True.

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

If you wanted to know the lowest and highest numerical values of a column, which statement would return these values?

A
SELECT min(column_name), max(column_name)
FROM table_name;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The … function calculates the largest value for the selected column.

A

max

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

Which ‘aggregate function’ statement will return the smallest numerical value in one column or more?

A
SELECT min(column_name)
FROM table_name;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which ‘aggregate function’ statement will return the largest numerical value in one column or more?

A
SELECT max(column_name)
FROM table_name;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

You have one column called Cost and another column which contains several different categories (or groups) called Products.
Give an example of a statement which will filter data in a table, to find the total cost of specific groups within the Products column.

A

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

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

How can we filter data in a table to find the ‘total cost, lowest value, highest value or average’ of a specific group?

A

SELECT column_name1, aggregate_function(column_name2)
FROM table_name
GROUP BY column_name1

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

What does the HAVING clause do?

A

The HAVING clause can be used to only list groups that have more than one row associated with them.

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

Give an example of a SQL statement with a HAVING clause.

A

SELECT column_name, sum(column_name)
FROM table_name
WHERE column_name operator value (optional)
GROUP BY column_name
HAVING aggregate_function (column_name) operator value;

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