Answer the question
In order to leave comments, you need to log in
Is there a ready-made function in PL/SQL (Oracle SQL) to select a value in field1 from multiple existing rows in a table that differ in the date in field2?
Oracle database.
PL/SQL language.
Only write select queries are allowed.
The table_name table has rows ranging from zero to several rows of the form:
key field_name date_field person_key
--- --- --- ---
3 Thom 01.01.1947 43464
7 Emma 02.02.2001 43464
5 Elza 07.07.1980 43464
4 Nelson 03.03.1955 32543
Answer the question
In order to leave comments, you need to log in
Read about KEEP (DENSE_RANK FIRST ORDER BY date_field ASC) or OVER (PARTITION BY person_key ORDER BY date_field)
As far as I understand the question, you need something like this:
SQL> select * from cawa.qqq where PERSON_KEY=43464 and DATE_FIELD=( select max (DATE_FIELD) from cawa.qqq where PERSON_KEY=43464 );
KEY FIELD_NAME DATE_FIELD PERSON_KEY
---------------------------------------------------- ----------------------- ----------------------
7 Emma 02-02-2001 00:00:00 43464
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question