Difference between revisions of "Find duplicates"

From MyWiki
Jump to: navigation, search
(Created page with "<source lang="sql"> select emosid, count(username) as cnt from staffuser_copy group by emosid having cnt >1; </source>")
 
 
Line 1: Line 1:
 
<source lang="sql">
 
<source lang="sql">
 
select emosid, count(username) as cnt from staffuser_copy group by emosid having cnt >1;
 
select emosid, count(username) as cnt from staffuser_copy group by emosid having cnt >1;
 +
</source>
 +
Getting rid of duplicate lines in a multi column table
 +
<source lang="sql">
 +
SELECT DISTINCT state, city
 +
FROM customers
 +
WHERE state IS NOT NULL
 +
ORDER BY state, city
 
</source>
 
</source>

Latest revision as of 17:50, 21 October 2014

SELECT emosid, COUNT(username) AS cnt FROM staffuser_copy GROUP BY emosid HAVING cnt >1;

Getting rid of duplicate lines in a multi column table

SELECT DISTINCT state, city
FROM customers
WHERE state IS NOT NULL
ORDER BY state, city