Skip to content

Tag: duplicates

SQL query for duplicate rows based on 2 columns

I have 3 tables movie, rating and reviewer movie has 4 columns movieID, title, year, director rating has 4 columns reviewerID, movieID, stars, ratingDate reviewer has 2 columns reviewerID, name How do I query reviewer who rated the same movie more than 1 time and gave it higher rating on the second review. Th…

How to delete rows that have duplicate column combination

I need to delete some rows that have the same column combination (except ID). The row that should be kept is the one that has the maximum reference date So, after the query the table should be like this I know that the query below will return the table I want, but I don’t know how to delete the “d…

Duplicated inner join results

With postgres I’m trying to get a single user and all their posts, but when I inner join the Users and Posts tables I receive this: QUERY: I’m also trying to do the same thing but as a json QUERY: I know why but I don’t know how to avoid it, can someone help me to get something like this:

SQL for finding multiple column matches (dups)

I’m trying to write a query to find all rows that have three columns in common with other rows. Imagine a person can only send one letter to another per day and I need to identify “dups” even though all of the columns may not be the same. I want to see all rows that have the same Sender_ID A…