Oracle Interview Questions | Duplicate Rows
Question
If a table contains duplicate rows, does a query result display the duplicate values by default? How can you eliminate duplicate rows from a query result?
in progress
0
Statistics
55 years
1 Answer
1381 views
Great Grand Master 0
Answer ( 1 )
Yes, the query will display duplicate rows.
To eliminate duplicate rows, you can try the following query:
WITH cte as (
Selec contact_id, first_name, last_name, email,
Row_number() OVER (PARTITION BY
first_name,last_name,email
ORDER BY
first_name,last_name,email)row_num
FROM Contacts
)
DELETE from cte where row_num > 1