When I run the statement below it is returning 3 records. I only want the MAXimum Cost. I tried DISTINCT to see if that would help but it didn't. How can I get it to give the the max cost?
strSQL = "SELECT DISTINCT Max(DealDetail_Hdr.COST) AS MaxAppear, DealDetail_Hdr.Item, Deals.From " _
& "FROM (Clients " _
& "INNER JOIN Deals on Clients.ID = Deals.ClientId) " _
& "INNER JOIN DealDetail_Hdr " _
& "ON Deals.DealID = DealDetail_Hdr.DEALID " _
& "WHERE clientid = " & sID & " AND Item = 'Appearance'" _
& " GROUP BY DealDetail_Hdr.Item, Clients.ID, Deals.From"
Set rst = db1.OpenRecordset(strSQL)
If rst.RecordCount > 0 Then
sMaxRate = rst!MaxAppear
sItem = rst!Item
If IsDate(rst!From) Then
sMaxFrom = rst!From
End If
End If
Thanks
Trudye
strSQL = "SELECT DISTINCT Max(DealDetail_Hdr.COST) AS MaxAppear, DealDetail_Hdr.Item, Deals.From " _
& "FROM (Clients " _
& "INNER JOIN Deals on Clients.ID = Deals.ClientId) " _
& "INNER JOIN DealDetail_Hdr " _
& "ON Deals.DealID = DealDetail_Hdr.DEALID " _
& "WHERE clientid = " & sID & " AND Item = 'Appearance'" _
& " GROUP BY DealDetail_Hdr.Item, Clients.ID, Deals.From"
Set rst = db1.OpenRecordset(strSQL)
If rst.RecordCount > 0 Then
sMaxRate = rst!MaxAppear
sItem = rst!Item
If IsDate(rst!From) Then
sMaxFrom = rst!From
End If
End If
Thanks
Trudye