Using Max() function to select group values

I’ve got a table like this:

     SKU    ITEM      VALUE
    1503796 1851920 0,9770637
    1503796 1636691 0,9747891
    1503796 1503781 0,9741025
    1503796 3205763 0,9741025
    1503801 1999745 0,9776622
    1503801 1999723 0,9718825
    1503801 3651241 0,9348839
    1503801 1773569 0,9331309
    1503811 1439825 0,97053134
    1503811 1636684 0,96297866
    1503811 1636671 0,96003973
    1503811 1600553 0,9535771
    1503818 1636708 0,9440251
    1503818 1636709 0,9440251
    1503818 1779789 0,9423958
    1503818 3322310 0,9369579

I need to get output like this (grouped with max value):

SKU      ITEM     VALUE
1503796 1851920 0,9770637
1503801 1999745 0,9776622
1503811 1439825 0,97053134
1503818 1636708 0,9440251

tried to use smth like this:

select SKU, ITEM, VALUE from import
where value=(select max(value) from import )

But it select only one row with max value. How to rewrite query?


Source: oracle

Leave a Reply