#SQL data validation
1 messages · Page 1 of 1 (latest)
You can use GROUP_BY and HAVING.
Ex. (with one col for simplicity)
SELECT column1 FROM my_table GROUP BY column1 HAVING count(*) > 1;
What more info do you need? Lol
Okay, that’s what I saw online but when I tried this I got many rows lol. I guess my table is wrong
This will return the owner_id that has more than 1 notebook
But you can include other info if you want too or count the number of columns
But I'd say you're problem is weird. Don't you have an unicity constraint on your columns? Or the goal is that you want to convert them into unique columns.
Yeah, that make sense.
You can do:
SELECT count(*) FROM my_table GROUP BY col1, col2 HAVING count(*) > 1;
This should return the number of duplicated row based on col1 and col2 uniqueness
Yea