Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> SQL Problem
I'm using 9i DB. I have table Ledger with pri. key Ledger_id, It has say two
other fields Customer_ID and Transaction_Type_id. Now ofcourse the other two
are not unique. What I want is to find all records with transaction_type_id
= 4 with the condition that the previous transaction_type_id is 92 and one
before the previous is 24 for the same customer_id ( the customer_id should
be the same)
So for example
Ledger_id Customer_id Transaction_type_id
1 1 1 2 1 24 3 2 5 4 1 92 5 3 16 6 1 4
You can see that ledger_id # 6 is the record my query should bring because it has ( for customer_id 1)
so it meets all conditions.
What would be the sql query that would bring all such records which meet the
above conditions
thx. Received on Sat Jan 08 2005 - 23:52:30 CST