Posted: Mon Jul 03, 2006 7:05 am Post subject: removing duplicate values from a table
Members,
I want to output all the duplicate records from a table assuming ITEMNO,ITEMNAME are character type data and ITEMQUANTITY being numeric data.Can anybody help me out in the requirement ?
Code:
INPUT
ITEMNO ITEMNAME ITEMQUANTITY
------ -------- ------------
01 A 10
01 A 10
01 A 10
02 B 20
04 C 20
04 C 30
04 C 20
06 D 40
07 C 30
06 D 40
DESIRED OUTPUT
ITEMNO ITEMNAME ITEMQUANTITY
------ -------- ------------
01 A 10
01 A 10
01 A 10
04 C 20
04 C 20
06 D 40
06 D 40
Joined: 26 Nov 2002 Posts: 12383 Topics: 75 Location: San Jose
Posted: Mon Jul 03, 2006 8:14 am Post subject:
mfuser,
Try this untested Sql
Code:
SELECT *
FROM TABLE
WHERE (ITEM_NO,ITEM_NAME,ITEM_QTY) IN (SELECT ITEM_NO
,ITEM_NAME
,ITEM_QTY
FROM TABLE
GROUP BY ITEM_NO
,ITEM_NAME
,ITEM_QTY
HAVING COUNT(*) > 1)
;
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum