W3. SQL Min and Max Flashcards

1
Q

Q: What does the SQL MIN() function do?

A

A: Returns the smallest value in a selected column.

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

Q: What does the SQL MAX() function do?

A

A: Returns the largest value in a selected column.

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

Q: Write a query to find the lowest price in the “Price” column of the “Products” table.

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

Q: Write a query to find the highest price in the “Price” column of the “Products” table.

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

Q: What is the syntax for using MIN() or MAX() with a condition?

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

Q: How can you give a descriptive name to the result column of MIN() or MAX()?

A

A: Use the AS keyword to set an alias, e.g.,
SELECT MIN(Price) AS SmallestPrice.

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

Q: Write a query to find the smallest price in the “Products” table and label it as “SmallestPrice.”

A
SELECT MIN(Price) AS SmallestPrice 
FROM Products;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Q: How do you use MIN() with GROUP BY to return the smallest price for each category?

A
SELECT MIN(Price) AS SmallestPrice, CategoryID 
FROM Products 
GROUP BY CategoryID;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly