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!

Query help to get last 24 hours data

Ricky007Apr 2 2020 — edited Apr 2 2020

Dear Experts,

Please help to get least date value for 24 hours

CREATE TABLE TXN_DTL

(

ID NUMBER,

CUST_ID NUMBER,

REG_DATE TIMESTAMP DEFAULT SYSTIMESTAMP,

STATUS VARCHAR2(20)

);

INSERT INTO TXN_DTL VALUES(1,111,'02-MAR-20 10.24.32.110795 AM','SUCCESS');

INSERT INTO TXN_DTL VALUES(2,111,'02-APR-20 01.44.54.110795 PM','SUCCESS');

INSERT INTO TXN_DTL VALUES(2,111,'02-APR-20 03.36.22.110795 PM','SUCCESS');

INSERT INTO TXN_DTL VALUES(4,111,'02-APR-20 05.42.54.110795 PM','SUCCESS');

CREATE TABLE REG_TB

(

REGNAME VARCHAR2(20),

R_CUST_ID NUMBER,

REG_DATE TIMESTAMP DEFAULT SYSTIMESTAMP

);

INSERT INTO REG_TB VALUES ('JOHN',111,'02-APR-20 09.42.54.110795 PM');

Here I want the result for least registration date in txn_detl(window period less than 24 hours) table based on reg_tb.

Expected result is

02-APR-20 01.44.54.110795 PM  -- > Because john registered on 02-APR-20 09.42.54.110795 PM and minus 24 hours will be 01-APR-20 09.42.54.110795 PM.

so after 01-APR-20 09.42.54.110795 PM I to find the least date .(i.e 02-APR-20 01.44.54.110795 PM )

Please help

This post has been answered by Solomon Yakobson on Apr 2 2020
Jump to Answer
Comments
Post Details
Added on Apr 2 2020
8 comments
18,692 views