sql - Finding duplicates (one row/ea) and listing number of duplicates per lookup code -


I am trying to query for products with duplicates, but with only one line per duplicate entry. I also want to show every entry to show how many other people like it. Even I still have a lot of things, but many of its errors are appreciated for how effective and troubleshooting tips are.

  SELECT p1.id AS product_id, p1.lookup_code AS product_lookup_code, p1.name AS product_name, p2.id AS duplicate_id, p2.lookup_code AS Duplicate_lookup_code, p2.name AS duplicate_name, COUNT (* ) (As products from P1 Inner on PO on P1 .lookup_code = p2.lookup_code INNER P.Id = Produce on item.Product_ID WHERE p1.id! = P2.id and items.Uvailable = true and item Estimate = true and items. Listed = False) 1 LIMIT 5000  

  SELECT p.id, p.lookup_code, p. By name, join TDUplacetCentContact product P INNER (SELECT count (id) as duplicate_ count, lookup_code products group lookup copy by counting (ID)> 1) t.lookup_code = products.lookup_code;  

Comments