sql min()

SQL Functions

homeBack

Next

The MIN() Function

  • The MIN() Function

    The MIN() function returns the first value of the selected column.

    SQL MIN() Syntax

    SELECT MIN(column_name) FROM table_name

  • SQL MIN() Example

    We have the following “Orders” table:

    OrderID Date Price Customer
    1 2012/12/12 1000 Joy
    2 2012/12/16 1600 Sam
    3 2012/12/22 1700 Arjun
    4 2012/12/23 1300 Joy
    5 2012/12/30 2300 John
    6 2012/12/31 1400 Joy

    Now we want to find the MIN value of the “Price” column.

    We use the following SQL statement:

    SELECT MIN(OrderPrice) AS SmallestOrderPrice FROM Orders

    The result-set will look like this:

    SmallestOrderPrice
    1000

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s