Jump to content

MIN() and MAX()


M Vishnu vardhan

Recommended Posts

Hello, @M Vishnu vardhan

MIN() function :

  • The MIN() function returns the smallest value in the specified table field(column).
  • For example, let's suppose we want to know the year in which the oldest movie in our library was released, we can use MySQL's MIN() function to get the desired information.
SELECT MIN(`year_released`) FROM `movies`;

Execute above query in MySQL the output look like that :

MIN('year_released')

2005

MAX() function :

  • The MAX() function is the opposite of the MIN() function. It returns the largest value from the specified table field(column).
  • Let's assume we want to get the year that the latest movie in our database was released. We can easily use the MAX() function to achieve that.
SELECT MAX(`year_released`)  FROM `movies`;

Execute above query in MySQL the return output look like that :

MAX('year_released')

2019

I hope above information will be useful for you.
Thank you.
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...