I have a tables that has replicated rows. The only thing different is the FLD_ID. I need to select into a temp table the one with the lowest FLD_ID. The following gives me the replicated ones. Any help?
SELECT
*FROM
folder_id
WHERE
EXISTS (SELECT NULL
FROM folder_id b
WHERE
b.stock = folder_id.stock
AND b.part = folder_id.part
GROUP BY b.a_stock , b.part
HAVING folder_id.fld_id < MAX(b.fld_id))
table looks like this.
fld_id stock part
100 4 991
101 4 991
102 4 991
103 5 431
104 6 881
105 6 881
I need a temp table with this.
fld_id stock part
100 4 991
104 6 881
SELECT
*FROM
folder_id
WHERE
EXISTS (SELECT NULL
FROM folder_id b
WHERE
b.stock = folder_id.stock
AND b.part = folder_id.part
GROUP BY b.a_stock , b.part
HAVING folder_id.fld_id < MAX(b.fld_id))
table looks like this.
fld_id stock part
100 4 991
101 4 991
102 4 991
103 5 431
104 6 881
105 6 881
I need a temp table with this.
fld_id stock part
100 4 991
104 6 881