Here is a sample query using the MIN and MAX functions in T-SQL:
SELECT MIN(Price) AS MinPrice, MAX(Price) AS MaxPrice
FROM Products;
This query selects the minimum and maximum values for the Price column from the Products table. The results of the query will be a single row containing the minimum and maximum values for the Price column.
Here is how the query works:
- The SELECT clause specifies the columns that will be included in the query results. In this case, we are using the MIN and MAX functions to calculate the minimum and maximum values for the Price column.
- The FROM clause specifies the table that will be used in the query. In this case, we are selecting from the Products table.
- The MIN and MAX functions are applied to the Price column to calculate the minimum and maximum values, respectively.
- The results of the query will be a single row containing the minimum and maximum values for the Price column. The AS keyword is used to specify an alias for each column in the query results, which makes it easier to refer to the columns in later parts of the query or in other queries.
Want to learn more about aggregate functions in SQL Server?
https://stevestedman.com/aggregation
More from Stedman Solutions:
Steve and the team at Stedman Solutions are here for all your SQL Server needs.
Contact us today for your free 30 minute consultation..
We are ready to help!