selecting a column based on a minimum value of another column

前端 未结 3 1121
[愿得一人]
[愿得一人] 2021-01-13 08:46

I have the following table.

test_type |  brand  | model  | band | firmware_version | avg_throughput
-----------+---------+--------+------+-----------------+-         


        
3条回答
  •  旧时难觅i
    2021-01-13 09:14

    This should be what you're looking for if I'm reading your post correctly, and I think it's a pretty easily readable way of doing it. :-)

    WITH min_firmware_version (model, firmware_version)
    AS
    (
        SELECT
            model,
            MIN(firmware_version)
        FROM temp_table
        GROUP BY
            model
    )
    SELECT
        temp_table.model,
        temp_table.firmware_version,
        temp_table.avg_throughput
    FROM temp_table
    INNER JOIN min_firmware_version
        ON temp_table.model = min_firmware_version.model
        AND temp_table.firmware_version = min_firmware_version.firmware_version
    

提交回复
热议问题