Search code examples
sqloracle-databasegreatest-n-per-group

how do i get 1 of the data with all the same columns in oracle?


Let's say we have some data;

id          1   2   3
price       5   5   7
old_price   5   5   8

I want it like this;

id          1    3
price       5    7
old_price   5    8

How its work in oracle?


Solution

  • I think you could do something like this:

     select min(id) as id, price, old_price from your_table_name group by price, old_price