You can't directly do that in MySQL because there is no function to urlencode
or urldecode
strings.
You will have to create a User Defined Function to handle that process. Once you have that function just go for a simple group by
with a having
clause.
If UDFs are not an option, the only workaround I can think of is manually replacing the chars (under your own risk):
SELECT REPLACE(email, "%40", "@") DuplicateEmail, COUNT(*) Amount
FROM t
GROUP BY DuplicateEmail
ORDER BY Amount desc
Fiddle here.
Output:
| DUPLICATEEMAIL | AMOUNT |
---------------------------
| abc@gmail.com | 2 |
| abcd@gmail.com | 2 |
| xyz@gmail.com | 1 |