Duplicate sql query
SELECT column_nameFROM table
GROUP BY column_nameHAVING COUNT(*) > 1
Example.
select inventory_item_id,count(inventory_item_id)
from mtl_system_items_b
where inventory_item_id = 114785
group by inventory_item_id
having count(inventory_item_id) >1
from mtl_system_items_b
where inventory_item_id = 114785
group by inventory_item_id
having count(inventory_item_id) >1
Here's a handy query for finding duplicates in a table. Suppose you
want to find all email addresses in a table that exist more than once:
SELECT email, COUNT(email) AS NumOccurrences FROM users GROUP BY email HAVING ( COUNT(email) > 1 )
You could also use this technique to find rows that occur exactly once:
SELECT email FROM users GROUP BY email HAVING ( COUNT(email) = 1 )
simple
------
select job_number, count(*)
from jobsgroup by job_numberhaving count(*) > 1;
another way
===========
SELECT * FROM TABLE AWHERE EXISTS ( SELECT 1 FROM TABLE WHERE COLUMN_NAME = A.COLUMN_NAME AND ROWID < A.ROWID)
No comments:
Post a Comment