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!

Using MAX on an INNER JOIN

PSULionRPJun 23 2009 — edited Jun 23 2009
Is there any way to use MAX on an INNER JOIN???

I am getting the MAX Date row on a previous INNER JOIN and then I want to use that result row to get an Account Balance. I know it's hard to explain without the SQL but I'll try...

So I want the MAX(BILLHDR.dt_bill)'s Account Balance...

SELECT PYMTADJ.ky_payment_adjustment,
PYMTADJ.ky_enroll,
PYMTADJ.dt_payment_adjustment,
PYMTADJ.at_payment_adjustment,
MAX(BILLHDR.dt_bill) Last_Bill_Date,
MAX(BILLHDR.dt_reading_from) "Last Bill Period From Date",
MAX(BILLHDR.dt_reading_to) "Last Bill Period To Date",
BILLHDR2.at_bill_account_balance
FROM PVIEW.PAYMENT_ADJUSTMENT PYMTADJ
LEFT OUTER JOIN PVIEW.BILL_HDR BILLHDR
ON PYMTADJ.ky_enroll = BILLHDR.ky_enroll
AND BILLHDR.dt_bill <= '15-Jun-2009'
INNER JOIN PVIEW.BILL_HDR BILLHDR2
ON BILLHDR.ky_enroll = BILLHDR2.ky_enroll
AND MAX(BILLHDR.dt_bill) = BILLHDR2.dt_bill

Any help would be GREATLY appreciated.

Thanks.

PSULionRP
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 21 2009
Added on Jun 23 2009
7 comments
3,313 views