Removing exact duplicate rows from presto
Asked Answered
M

1

6

With the following table (assuming it has many other rows and columns), how could I query it while removing duplicates?

order_id customer_name amount bill_type
1 Chris 10 sale
1 Chris 1 tip
1 Chris 10 sale

Note that while all 3 rows are about the same order, only row 3 is a duplicate -- since row 2 tells us about the tips of that order.

Using distinct order_id would remove rows 2 and 3, while I am looking to only remove row 3.

Appreciate any ideas

Mraz answered 26/1, 2021 at 18:2 Comment(0)
B
10

If you want a new result set, you can use:

select distinct t.*
from t;

I would suggest saving this into a new table, if you need to materialize the result.

Bopp answered 26/1, 2021 at 18:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.