SubQuery How To question
Hey Folks,
I am having trouble wrapping my head around a subquery problem. Briefly, I want to find MIN(Invoice_date) by Customer_ID in Table, then select CustomerTable data for those whose MIN(Invoice_date) is > 2024-01-01.
Table:
Customer_ID Invoice_date
A 2023-01-01
A 2023-02-01
B 2024-03-01
B 2025-01-01
C 2024-04-01
C 2025-03-01
SELECT Customer_ID, min(Invoice_date) FROM Table GROUP BY Customer_ID ORDER BY Customer_ID;
Gives me:
Customer_ID Invoice_date
A 2023-01-01
B 2024-03-01
C 2024-04-01
Question 1) How do I get Customer_IDs and their Min(invoice_date) WHERE min(invoice_date) >= '2024-01-01'? Results look like:
Customer_ID Invoice_date
B 2024-03-01
C 2024-04-01
Question 2) How do I join the results to CustomerTable on Customer_ID:
CustomerTable:
Customer_ID Customer_Name
A Alpha
B Beta
C Charlie
To get the following Results:
Customer_ID Customer_Name MinInvoice_Date
B Beta 2024-03-01
C Charlie 2024-04-01
Thanx
Subject
Written By
Posted
SubQuery How To question
May 15, 2025 01:17PM
Sorry, only registered users may post in this forum.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.