I am really stuck with an sql query... I hope someone can help shed some light for me.
Here is what my table looks like
mysql> show fields from france_data;
+----------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| email | varchar(45) | YES | | NULL | |
| name | varchar(45) | YES | | NULL | |
| lastname | varchar(45) | YES | | NULL | |
| quality | varchar(45) | YES | | NULL | |
| country | varchar(45) | YES | | NULL | |
| state | varchar(45) | YES | | NULL | |
| year | varchar(45) | YES | | NULL | |
| owner | varchar(45) | YES | | NULL | |
+----------+-------------+------+-----+---------+----------------+
9 rows in set (0.00 sec)
Here's the catch, I have duplicate data in my table, I would like to pull out all data from this table, non-duplicated based on the email.
I ran a simple count like this:
mysql> select count(*) from france_data;
and this is the result set:
+----------+
| count(*) |
+----------+
| 2405259 |
+----------+
1 row in set (0.01 sec)
Now I tried to run a count like this:
mysql> select count(*) from france_data group by email;
Just to see how many unique records I have. Unfortunately this times out.
Does any one know how I can do a count of unique rows and select of the same type?
In Excel, there are several ways to filter for unique values—or remove duplicate values: To filter for unique values, click Data > Sort & Filter > Advanced. To remove duplicate values, click Data > Data Tools > Remove Duplicates.
The SELECT DISTINCT statement is used to return only distinct (different) values. Inside a table, a column often contains many duplicate values; and sometimes you only want to list the different (distinct) values.
The unique values are fetched when we use the distinct keyword. SELECT DISTINCT returns only distinct (different) values. DISTINCT eliminates duplicate records from the table. DISTINCT can be used with aggregates: COUNT, AVG, MAX, etc.
We can use the MySQL DISTINCT clause to return a single field that removes the duplicates from the result set. For example: SELECT DISTINCT state FROM customers; This MySQL DISTINCT example would return all unique state values from the customers table.
Please try this
SELECT COUNT(DISTINCT email) FROM france_data
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With