Can somebody help to rewrite this query to delete records? I having trouble getting the min(a.scancode) in some way or shape in the where clause.
select a.location, min(a.scancode) as tobedeleted
from mig_container_location_1 a
where a.location in (select b.location
from mig_container_location_1 b
where b.LOCATION like 'v%t%l%b%_____%'
group by b.location
having count(b.location) = 3)
group by a.LOCATION;
Below an example of a table. What I would like to do is delete the lowest scancode of each location.
| Scancode | Location |
|---|---|
| 120545254 | VB05 T06 B09 |
| 120545255 | VB05 T06 B09 |