3 Replies Latest reply on Jun 11, 2017 6:36 PM by user19752

    SQL Select Group By Min() - but select other

    firebase

      This is a crosspost from Stackoverflow firebird - SQL Select Group By Min() - but select other - Stack Overflow

      But since this is working in Firebird but not with the limited FSQL I thought its best to take it over to this place.

       

      Question:

       

      I want to select the "ID" of the Table "Products" with the lowest "Price" Grouped By "Product".

       

      ID    Product    Price

      1     123        10

      2     123        11

      3     234        20

      4     234        21

       

      Wich by logic would look like this:

       

      SELECT

        ID,

        Min(Price)

      FROM

        Products

      GROUP BY

        Product

       

      But I dont want to select the Price itself, just the ID.

       

      Result should be:

      1

      3