Hello
im trying to make a Function that retruns a value.
in my function i have this script:
WITH t_new AS
(
SELECT PersIDOLD, PersIDNEW, RightsMUT,
SUM(gap) over(ORDER BY PersIDOLD, PersIDNEW) grp
FROM
(
SELECT h1.*,
CASE
WHEN h1.PersIDNEW = lag(h1.PersIDNEW)
over(ORDER BY h1.PersIDOLD, h1.PersIDNEW)
OR h1.PersIDOLD = lag(h1.PersIDOLD)
over(ORDER BY h1.PersIDOLD, h1.PersIDNEW)
THEN 0
ELSE 1
END gap
FROM HelpTable1 h1
)
)
SELECT PERSIDNEW, RIGHTSMUT
FROM t_new
WHERE grp =
(
SELECT grp FROM t_new WHERE PersIDNEW = 12 -- going to be a variable
)
the return is like this:
now i want to return row 3
coze it has a 1
in row RightsMUT
how can i do this?
i tried to do it with 2 With
but oracle does not support 2 with yet :/
greets Auro