1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

finding maximum and minimum in a column

Discussion in 'SQL Server' started by nmh, Apr 29, 2008.

  1. nmh

    nmh New Member

    Joined:
    Sep 18, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    In a table called Item there are several items. Item with same can be there such as chocolate, toffee but they have a different Item code. How can I find the Same item with maximum and minimum values.?(That is chocolate with with maximum and minimum prize).

    I thank you in advanced.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    Here they come

    Code:
    Select * from chocolate where price = (Select max(price) from chocolate)
    Code:
    Select * from chocolate where price = (Select min(price) from chocolate)
     
  3. nmh

    nmh New Member

    Joined:
    Sep 18, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    shabbir
    Thanks a lot
    cheers
     

Share This Page