Home » SQL & PL/SQL » SQL & PL/SQL » Record Plus Prior Record - Single Row
Record Plus Prior Record - Single Row [message #678203] Fri, 15 November 2019 21:23 Go to previous message
GIL149
Messages: 1
Registered: November 2019
Junior Member
I have Table1 that contains Cust, Trans_Type, Date...

What I am trying to do is collect all records between a date range...then on the same ROW for each record I want to add two fields that show me the prior Trans_Type and Date to the Transaction pulled...

I have a tried variations but I can't get it to pull the exact previous transaction...it pulls all previous transactions blowing up the report... Any ideas? Sorry if the syntax is not exactly PL SQL, just started with Oracle SQL Developer recently.

SELECT
T1.*,
T2.Trans_Type,
T2.Date
FROM TABLE1 T1
LEFT JOIN TABLE1 T2 ON T2.CUST=T1.CUST AND T2.DATE<T1.DATE
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Query performance condundrum.
Next Topic: question for reverse
Goto Forum:
  


Current Time: Mon Sep 21 07:23:50 CDT 2020