Tuesday, 15 January 2013

sql - delete rows based in the value of the previous row in the same table -



sql - delete rows based in the value of the previous row in the same table -

i have table:

line content 245 route selection info 365 continued... 367 --- end 373 route selection info 424 --- end 454 --- end 462 pra subscriber configuration 491 --- end 545 --- end

i need delete rows content have same values previous row, don't have eliminate rows same value. need maintain rows value of content different previous row. in other word need table this:

line content 245 route selection info 365 continued... 367 --- end 373 route selection info 424 --- end 462 pra subscriber configuration 491 --- end

i can't delete based on value of column line because value of column alter everyday. have delete records based on values of column content.

a simple way utilize nested query lag find duplicate lines, , delete them in outer query;

delete mytable line in ( select case when content = lag(content) on (order line) line end r mytable );

an sqlfiddle test with.

sql oracle

No comments:

Post a Comment