AVG, MIN, MAX Aggregate Function Use

Here is the link of the project I am working on:


What would be returned from these queries:

The MIN() aggregate function returns the smallest value in a column.

SELECT title, medium, MIN(date)
FROM met;


The MAX() aggregate function takes the name of a column as an argument and returns the largest value in a column.

SELECT title, medium, MAX(date)
FROM met;


The AVG() aggregate function returns the average value in a column.

SELECT title, medium, AVG(date)
FROM met;

Question: How does that compute a result for title and medium when the AVG returned doesn’t have value that matches it?

Hi, Welcome to the forums.

Dates are tricky sometimes!
You cannot use AVG on that date column in the same way you’d use MAX & MIN in this exercise (same way you couldn’t use SUM here).
If you check out the table’s schema at the bottom of the lesson, you’ll see that it’s data type is TEXT.

You’d have to convert it using CAST or possibly DATEDIFF & DATEADD (I’m not sure which one, specifically. You’d have to test them out in that lesson)
Ex: CAST(expression AS datatype(length))

See here:

and here for reference:

1 Like

I understand it better now, Thank you for the answer and for this tip. I think it will be useful in the future and I hope it will be helpful for others.

You’re welcome.
Happy coding!

1 Like