Oracle SQL GROUP BY “not a GROUP BY expression” help

后端 未结 3 1421
庸人自扰
庸人自扰 2020-12-30 04:16

I have a table some_table like

+--------+----------+---------------------+-------+
| id     | other_id | date_value          | value |
+--------         


        
3条回答
  •  鱼传尺愫
    2020-12-30 04:41

    Probably this is the simplest way

    SELECT id, other_id, date_value, value
    FROM some_table
    WHERE date_value in (SELECT MAX(date_value)
                         from some_table
                         GROUP BY other_id
                         HAVING other_id in (1,2,3));
    

    Test the above query here

提交回复
热议问题