self join help for an Oracle newbie
From: Abaza <mabaza25_at_DELETEusa.net>
Date: Thu, 10 Jun 1999 18:45:31 -0500
Message-ID: <7jpijf$122e$1_at_news.doit.wisc.edu>
Because of poor database design on an application that I inherited, I need to join two tables that have a one to many relationship while only outputting a single record. Specifically, I need to join the two tables on Table A primary key (CustomerID) to Table B's foreign key (CustomerID) while only keeping the record from Table B that has the lowest date value in a second field.
Date: Thu, 10 Jun 1999 18:45:31 -0500
Message-ID: <7jpijf$122e$1_at_news.doit.wisc.edu>
Because of poor database design on an application that I inherited, I need to join two tables that have a one to many relationship while only outputting a single record. Specifically, I need to join the two tables on Table A primary key (CustomerID) to Table B's foreign key (CustomerID) while only keeping the record from Table B that has the lowest date value in a second field.
[Quoted] I guess I could use VB to Loop through the two
tables but this may take forever...is there a way to do a self join on Table
[Quoted] B that grabs only the record with the lowest date for a singel CustomerID
and then join this resultset
to Table As?
Received on Fri Jun 11 1999 - 01:45:31 CEST