G
George Addison
I thought I might post this to see if there is a pro that
can help me. Here's what I want to do:
- I have two tables ('tblPositions', 'tblTrades')
- A relationship exists at tblPositions.ID =
tblTrades.PositionID
- I need to pull only one record from each relation set
(the one with the most recent TradeDate value) from the
tblTrades table
- I need to sort the retrieved records by TradeDate DESC
Here is the SQL statement that I have so far:
"Select DISTINCT tblTrades.PositionID as ID FROM
tblPositions, tblTrades WHERE tblPositions.Status = " &
Status & " AND tblTrades.PositionID = tblPositions.ID AND
tblTrades.TradeDate BETWEEN '" & Format
(StartDate.Date, "yyyy-MM-dd") & "' AND '" & Format
(EndDate.Date, "yyyy-MM-dd") & "' ORDER BY
tblTrades.TradeDate DESC"
can help me. Here's what I want to do:
- I have two tables ('tblPositions', 'tblTrades')
- A relationship exists at tblPositions.ID =
tblTrades.PositionID
- I need to pull only one record from each relation set
(the one with the most recent TradeDate value) from the
tblTrades table
- I need to sort the retrieved records by TradeDate DESC
Here is the SQL statement that I have so far:
"Select DISTINCT tblTrades.PositionID as ID FROM
tblPositions, tblTrades WHERE tblPositions.Status = " &
Status & " AND tblTrades.PositionID = tblPositions.ID AND
tblTrades.TradeDate BETWEEN '" & Format
(StartDate.Date, "yyyy-MM-dd") & "' AND '" & Format
(EndDate.Date, "yyyy-MM-dd") & "' ORDER BY
tblTrades.TradeDate DESC"