Страница 1 из 1

удаление дубликатов

Добавлено: 12 июн 2003, 08:31
Lepsik
приехала таблица вида
create table lith( station int not null, from double not null, to double not null )

и надо бы все три поля сделать primary

insert into lith (station, from, to) values (1, 0, 5)
insert into lith (station, from, to) values (1, 5, 10)
insert into lith (station, from, to) values (1, 5, 10)
insert into lith (station, from, to) values (1, 10, 15)

как бы удалить 1,5,10 лишнее ?

понятно что сначала надо бы добавить в табличку
alter table lith add super_id int identity(1,1)

а дальше куда рыть ? с тремя-то полями ?

Добавлено: 12 июн 2003, 10:09
Lepsik
andrew2 писал(а):delete from lith
where exists
(select 1 from lith l where
l.super_id > lith.super_id
and l.station = lith.station
and l.from = lith.from and l.to = lith.to)

Только названия полей мне твои не нравятся,
с reserved words не совпадают?
на самом деле там from_, to_

спасибо огромное

Добавлено: 12 июн 2003, 10:52
папа Карло
super_id дропнуть не забудь :)

Добавлено: 17 июн 2003, 08:20
Lepsik
>>super_id дропнуть не забудь

обижаешь начальник :lol:

Добавлено: 17 июн 2003, 09:59
папа Карло
кто тебя знает. :lol: