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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

filter date and values max()

User_AC3QEMar 17 2021 — edited Mar 18 2021
Hello
I need to filter the fields dt_liberacao by the biggest date and the value (peso_pre, peso_pos e peso_pos_ult)

if the value of the largest date is null, you need to get the second largest.

exempl:
image.png

it is necessary that only the values ​​peso_pre 78.15, peso_pos 76.45 and peso_pos_ult 76.9 remain on the line

CREATE TABLE ktv_hd (
DT_LIBERACAO DATE ,
PESO_PRE VARCHAR2(30) ,
PESO_POS VARCHAR2(20) ,
PESO_POS_ULT VARCHAR2(20) 

/
INSERT INTO ktv_hd VALUES (TO_DATE('03/02/2021 20:51:46','DD/MM/YYYY HH24:MI:SS'),NULL,'76,45','76,9');
INSERT INTO ktv_hd VALUES (TO_DATE('03/02/2021 19:37:19','DD/MM/YYYY HH24:MI:SS'),NULL,'76,9',NULL);
INSERT INTO ktv_hd VALUES (TO_DATE('03/02/2021 16:30:50','DD/MM/YYYY HH24:MI:SS'),'78,15','76,9',NULL);
INSERT INTO ktv_hd VALUES (TO_DATE('01/02/2021 21:25:50','DD/MM/YYYY HH24:MI:SS'),NULL,'76,9','77');
INSERT INTO ktv_hd VALUES (TO_DATE('01/02/2021 17:21:58','DD/MM/YYYY HH24:MI:SS'),'79',NULL,NULL);

This post has been answered by Frank Kulash on Mar 18 2021
Jump to Answer
Comments
Post Details
Added on Mar 17 2021
3 comments
612 views