I have data that are in two tables, and I have a query that combines data, as shown below. I am trying to eliminate duplicates based on the Id column, where I select the record with the oldest schedule date. Can someone kindly help me with an SQL statement for this?
|ID |SecID |ReportingDate |SplitDate |Adjustor|
|1465 |2 |31-Dec-09 |01-Nov-10 |0.1 |
|1465 |2 |31-Dec-09 |27-Dec-12 |0.2 |
|1466 |2 |31-Dec-10 |27-Dec-12 |0.2 |
|1468 |2 |31-Dec-11 |27-Dec-12 |0.2 |
|1469 |2 |31-Dec-08 |01-Nov-10 |0.1 |
|1469 |2 |31-Dec-08 |27-Dec-12 |0.2 |
The result should be as follows:
|ID |SecId |ReportingDate |Adjustor |
|1469 |2 |31-Dec-08 |0.1 |
|1465 |2 |31-Dec-09 |0.1 |
|1466 |2 |31-Dec-10 |0.2 |
|1468 |2 |31-Dec-11 |0.2 |
Additional Information:
Let me explain what I'm trying to do here.
, secId ( ) .
splitdetails, , , secId () , .
:
- - secId, , 1.
- secId Splits, , , , , , .
, :
| ID | SecId | ReportingDate | |
| 1469 2 31--08 0,1
| 1465 2 31--09 0,1
| 1466 2 31-Dec-10 0,2
| 1468 2 31-Dec-11 0.2
| 1467 2 31-Dec-12 1
, , - SELECT Gotten.ID, Gotten.SecID, Gotten.ReportingDate, Gotten.SplitDate, Adjustor
(SELECT tblFundamentalsDetails.id, tblFundamentalsDetails.SecId, tblFundamentalsDetails.ReportingDate, tblSplitDetails.SplitDate, tblSplitDetails.Adjustor
FROM tblFundamentalsDetails
LEFT JOIN tblSplitDetails
ON (tblFundamentalsDetails.ReportingDate