Solve It with SQL: Removing Points from a Linked List

preview_player
Показать описание
In this guest video, Natalka shows how you can use SQL to traverse a linked list of co-ordinates. She then demonstrates how to remove points that are not on a corner.

She does this using the analytic functions lag and lead.

============================
The Magic of SQL with Chris Saxon

Copyright © 2015 Oracle and/or its affiliates. Oracle is a registered trademark of Oracle and/or its affiliates. All rights reserved. Other names may be registered trademarks of their respective owners. Oracle disclaims any warranties or representations as to the accuracy or completeness of this recording, demonstration, and/or written materials (the “Materials”). The Materials are provided “as is” without any warranty of any kind, either express or implied, including without limitation warranties or merchantability, fitness for a particular purpose, and non-infringement.
Рекомендации по теме
Комментарии
Автор

This is awesome! we could probably also use the fact that corner point's two adjacent points have no common x or y value, something like:

with...-- omits testing data
select node from(
select '('||x||', '||y||')' node, ll.*, lag(x) over (order by sq) pre_x, lead(x) over (order by sq) as next_x,
lag(y) over (order by sq) pre_y, lead(y) over (order by sq) next_y from ll
) where (next_x != pre_x and next_y != pre_y)
or pre_x is null or next_x is null -- to include head and tail

yagexing
Автор

Isn't that wrong? sequence went 10 twice in video 11:13.

mongolwarrior
join shbcf.ru