I'm trying to make a query that will give me the slope of a pipe.
The ground elevation of the pipe ends are stored as attributes in the pipe's start/end nodes.
I made a query that works for a continious line, but if i need to make it work for a soft-splited line also.
select to_char((100*(
(select ((select Z from WW_POINT
where FID = (select FID_TO from WW_CONN
where FLOW = 2 and FID_FROM = (select FID from WW_LINE
where FID_ATTR =(select FID from WW_PIPE
where FID = {FID}))
union all
select FID_FROM from WW_CONN
where FLOW = 1 and FID_TO = (select FID from WW_LINE
where FID_ATTR = (select FID from WW_PIPE
where FID = {FID}))))
-
(select H_US from WW_PIPE where FID = {FID})) from dual)
-
(select ((select Z from WW_POINT
where FID = (select FID_TO from WW_CONN
where FLOW = 1 and FID_FROM = (select FID from WW_LINE
where FID_ATTR =(select FID from WW_PIPE
where FID = {FID}))
union all
select FID_FROM from WW_CONN
where FLOW = 2 and FID_TO = (select FID from WW_LINE
where FID_ATTR = (select FID from WW_PIPE
where FID = {FID}))))
-
(select H_DS from WW_PIPE where FID = {FID})) from dual)
)/(SELECT SUM(length)
FROM WW_LINE WHERE FID_ATTR = {FID})),'9990.999') from dual