Link to home
Start Free TrialLog in
Avatar of PHIL Sawyer
PHIL SawyerFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Retrieve forward values

Hi
I have a set of data as per the attachment (select company, date, amt, ref from mytable)... and want another column added
which is called Ref2  - see attachment for clarification.
NO PLSQL please.

RegardsEXP_EXCH.xlsx
SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Care to show the execution plan?  I modified the UNION WITH to use a real table and it accessed it more than once.  Maybe your testing showed something different.
first_value ... with a range like 1 following and unbounded following

just my 2 cents
that looks very much like last_value without a range

last_value(amt) over (partition by company order by ref, mydate)
>>that looks very much like last_value without a range

I'm not getting the correct values using your LAST_VALUE example.
Avatar of PHIL Sawyer

ASKER

Thanks guys - great work