I have a SQLite DB that has people LastName, FirstName, Department and I need to make a query that shows me any people with the same First & Last Names. I've found the following statement that supposedly does what I want for a single field, however it doesn't seem to work for me when I try to use it to pull all records with just the last name being the same. How can I do this?
Select myField From myTable Group by myField Where count(myField)>1
try:
Select
firstname,LastName,Count(*)
From myTable
Group by firstname,LastName
HAVING Count(*)>1
GROUP BY combines rows where the named values are the same.
HAVING removes groups that do not meet the condition.
The above query will list the first and last names, along with a count of duplicates for all first/last names that actually have duplicates.
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