wizard1923
Technical User
newbie with rudimentary knowledge of SQL queries here...trying to eliminate erroneous records with specific criteria. here is what i'm trying to accomplish:
select
update_datetime
,control_number
,record_type
from table1 inner join table2
on table1.field = table2.field
where update_datetime between 'x' and 'y'
results would look like:
update_datetime control_number record_type
2010-12-29-9.30.10 123456 1
2010-12-29-9.45.03 123456 2
2010-12-29-10.15.00 456789 1
2010-12-29-11.30.00 456789 1
what i need to do is:
1. if two records have the same control_number and one of them has a record_type of 2 - eliminate both records
2. if two records have the same control_number and both have the same record_type - keep only the record with latest update_datetime
Hope I've explained this thoroughly. Any help would be much appreciated.
select
update_datetime
,control_number
,record_type
from table1 inner join table2
on table1.field = table2.field
where update_datetime between 'x' and 'y'
results would look like:
update_datetime control_number record_type
2010-12-29-9.30.10 123456 1
2010-12-29-9.45.03 123456 2
2010-12-29-10.15.00 456789 1
2010-12-29-11.30.00 456789 1
what i need to do is:
1. if two records have the same control_number and one of them has a record_type of 2 - eliminate both records
2. if two records have the same control_number and both have the same record_type - keep only the record with latest update_datetime
Hope I've explained this thoroughly. Any help would be much appreciated.