Returning Lowest Value From Table

  • Hi this is my first time posting so Hope it is in the correct area.

    I have a table example below.

    Model Number, Price

    model1 , 10

    model1 , 15

    model2 , 20

    model2 , 25

    I would like to return the lowest value based on the price field. so results would look like.

    Model Number, Price

    model1 , 10

    model2 , 20

    I think I used select distinct in the past but cant seem to get it working.

    Can anyone suggest a way of doing this I had this working in the past but lost my db. and I havnt used sql for a looong time.

    Thanks for you help.

    John/.

  • Just a GROUP BY should do it

    SELECT [Model Number], MIN(Price) AS Price

    FROM myTable

    GROUP BY [Model Number]

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537
  • Hi Mark that worked just as I wanted.

    Thanks very much for your speedy reply.:-)

    John.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply