Comparision

  • Dear All,

    I have a to select all rows from cst table.In this table we have two cstid for each customer

    But the corresponding 'price' field shows different price.I want to select all the rows, which has less price than another one.

    For ex:

    CStid Price

    1000 14.98

    1000 7.53

    2000 83.57

    2000 176.87

    3000 23.07

    3000 3.67

    Result be

    1000 7.53

    2000 83.57

    3000 3.67

    How to do this.ie.Need to compare adjacent rows and pick the one with low value.Any help reg this highly appreciated.Many Thanks.

    Regards,

    SG

  • This looks remarkably like a homework assignment... have you covered the GROUP BY clause yet?

  • select CStid, MIN(Price) from Tablename group by CStid

    Ryan
    //All our dreams can come true, if we have the courage to pursue them//

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

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