TRIM and GROUP BY HAVING to detect duplicate values
Running vendor master dedup. Find vendor names that appear more than once after trimming whitespace and lowercasing. Show `normalized_name` and `dup_count`. I suspect at least one trailing-space duplicate is hiding in there.
| Column | Type | Key |
|---|---|---|
| vendor_id | INT | PK |
| vendor_name | TEXT | |
| category | TEXT | |
| country | TEXT | |
| onboarded_date | TEXT |
Each hint you reveal reduces the XP you can earn. Try the query first.
Duplicates here aren't exact — 'Acme' and 'acme ' are the same vendor to Mei, different rows to the database. Normalize the name before you count, and only keep groups that collapse to more than one row.
Group by the normalized name, then `HAVING COUNT(*) > 1`.
After TRIM + LOWER + GROUP BY, any group with COUNT > 1 is a suspect. The result set is short — that's expected for a well-maintained vendor list.