Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Need help with SQL (join)
"Daniel A. Morgan" wrote:
>
>
>> We have two tables, loan & transaction, related by the loan ID. I
>> need
>> to select all loans with a zero balance and the most recent
>> transaciton
>> being a payment. (Basically, final payments are supposed to be
>> entered
>> as payoff transactions but sometimes get entered as regular
>> payments. I
>> need to build a list of loans with those erroneous transactions.)
>>
>> Select Loans.Loan_ID from Loans, Trans
>> where Trans.Loan_ID=Loans.Loan_ID
>> and Trans.Tran_Type="Payment"
>> and Trans.Tran_Date=?????
>>
>> How do I specify the max(tran_date) for just that loan?
>
> If you mean to say "AND" as bold faced above then use a union.
>
> SELECT fields
> FROM table
> WHERE condition
> UNION
> SELECT fields
> FROM table
> WHERE different_condition
>
> Daniel A. Morgan
Why? The join works fine, my problem is defining the 'different_condition'. Received on Wed Jan 17 2001 - 11:59:43 CST
![]() |
![]() |