Thursday , April 25 2024

MIN and MAX Functions in SQL Server(TSQL)

 

We find the minimum value in a column in a dataset, with the MIN Function and we find the maximum value  in a column in a dataset, with the with the MAX Function.

Let’s make examples for a better understanding of MIN and MAX Functions.

Example:

First, we create a table with the help of the following script and add a few records into this table.

MIN Function Usage:

We find the minimum age value in the table with the following script.

MAX Function Usage:

We find the maximum age value in the table with the following script.

We usually use the MIN and MAX functions with GROUP BY Clause. You can find detailed information in the following article.

Group By Clause, SUM, MAX, MIN, AVG, COUNT and COUNT_BIG Functions in SQL Server

Loading

About dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories