Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Pick first occurrence of final value

JohnETDec 2 2016 — edited Dec 6 2016

If i have this data:

SELECT *

FROM

(

SELECT  'BIO' PROGRAM, 1 TIME_PERIOD FROM DUAL

UNION

SELECT  'BIO' PROGRAM, 2 TIME_PERIOD FROM DUAL

UNION

SELECT  'MATH' PROGRAM, 3 TIME_PERIOD FROM DUAL

UNION

SELECT  'MATH' PROGRAM, 4 TIME_PERIOD FROM DUAL

UNION

SELECT  'MATH' PROGRAM, 5 TIME_PERIOD FROM DUAL

) t1

How would I find the first TIME_PERIOD value that represents the final PROGRAM?

The answer will be TIME_PERIOD = 3.

But how do I get this result with an analytical function?

Think of this data as a student who has BIOLOGY as their first major in their first term.

But they change majors to MATH in the 3rd term and do not do any subsequent change in their major.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 3 2017
Added on Dec 2 2016
16 comments
2,991 views