 |
 |
Archives of the TeradataForum
Message Posted: Wed, 28 May 2003 @ 16:17:15 GMT
Subj: | | Re: Delete from a union |
|
From: | | Claybourne Barrineau |
I think this should work.
Hope it helps,
Clay
Delete from Customer
Where (sequence_number, name, address, age, type)
in
(
Select sequence_number,
name,
address,
age,
type
from customer customer1,
customer customer2
where customer1.name = customer2.name
and customer1.address = customer2.address
and customer1.age = customer2.age
and customer1.type = 'a'
and customer1.sequence_number = customer2.sequence_number - 1
union
Select sequence_number,
name,
address,
age,
type
from customer customer1,
customer customer2
where customer1.name = customer2.name
and customer1.address = customer2.address
and customer1.age = customer2.age
and customer2.type = 'b'
and customer1.sequence_number + 1 = customer2.sequence_number
);
| |