blog post

SELECT MIN returns the minimum value for a column.
SELECT MAX returns the maximum value for a column.
The general MIN syntax is:

SELECT MIN(column-name)
  FROM table-name

The general MAX syntax is:
SELECT MAX(column-name)
  FROM table-name

Problem: Find the cheapest product
SELECT MIN(UnitPrice)
  FROM Product

SQL SELECT MAX and MIN Examples

Problem: Find the largest order placed in 2016
SELECT MAX(TotalAmount)
  FROM [Order]
 WHERE YEAR(OrderDate) = 2016

Problem: Find the last order date in 2016
SELECT MAX(OrderDate)
  FROM [Order]
 WHERE YEAR(OrderDate) = 2016

MIN and MAX can also be used with numeric and date types.

  • Share This Story


Pleas give your valuable comments to improve the contents.

about author

Atul kumar shukla


I'm Atul Kumar Shukla, working as a web developer.
Welcome to my Blog. This is my personal blog where i post my own questions and answers , articles about ASP.Net., SQL Server, HTML, CSS, Jquery and many more..

Visit Profile

Leave a comment

Name
E-mail
Url
Message

Get More Stuff
Subscribing to the TheOneblogs newsletter and get intersting stuff and updates to your email inbox.
Your Email

 

Style Switcher

Change Color

×! We use cookies to improve your user experience. More information