Last active
December 5, 2017 20:54
-
-
Save johnhonan/15d65b5434d676ae364183712a18bbb4 to your computer and use it in GitHub Desktop.
Dupe example create tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE "HR"."PRODUCTS" | |
( "PRODUCT_ID" NUMBER, | |
"PRODUCT_DESC" VARCHAR2(30 BYTE) | |
); | |
Insert into HR.PRODUCTS (PRODUCT_ID,PRODUCT_DESC) values (10,'Oranges'); | |
Insert into HR.PRODUCTS (PRODUCT_ID,PRODUCT_DESC) values (11,'Apples'); | |
Insert into HR.PRODUCTS (PRODUCT_ID,PRODUCT_DESC) values (15,'Pineapples'); | |
Insert into HR.PRODUCTS (PRODUCT_ID,PRODUCT_DESC) values (34,'bananas'); | |
Insert into HR.PRODUCTS (PRODUCT_ID,PRODUCT_DESC) values (10,'Coconuts'); | |
Insert into HR.PRODUCTS (PRODUCT_ID,PRODUCT_DESC) values (15,'Pears'); | |
-- Now find the duplicate records | |
SELECT | |
product_id, | |
count(*) | |
FROM hr.products | |
GROUP BY product_id | |
HAVING count(*) > 1; -- Find duplicate entries |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment