SQL Question?
Posted in 1997
On SE 5.01, 4GL 4.12:
There has got to be a better way to do this:
I have a table
id char 16 unique index
bin char 4
dept char 3
activ_date datetime yr to min
I want to purge old data from this table whenever there is more than
one row for dept 004 with a duplicate bin number. (A part has been
moved to dept 004, consumed and another has been moved in to the same
bin)
If I declare a cursor for:
select bin
from table
where dept_id = "004"
group by bin
having count(*) > 1
I know which bins need to be purged
and can have an update cursor ordered by activ_date
and delete the first row where the bin matches from
the above cursor
using a delete where current cursor.....
I thought there was a way to "delete where min(activ_date)"
in one SQL statement, but I can't find it.
Is there an better way?
TIA,
Matt Brickley