First let me explain what my data is and what I want to get:
For every Project and every Trade there are multiple Bids
I want to get the range of the BidAmount so I came up with
Code:
SELECT dbo_Project.StatusCode, dbo_BidsReceivedDetail.TradeCode, dbo_BidsReceivedDetail.ProjectCode, dbo_BidsReceivedDetail.AlternateBidNumber,
Count(dbo_BidsReceivedDetail.BidAmount) AS CountOfBidAmount, CCur(Val(Min(dbo_BidsReceivedDetail.BidAmount))) AS MinOfBidAmount,
CCur(Val(Max(dbo_BidsReceivedDetail.BidAmount))) AS MaxOfBidAmount,
CCur(Val((Max([dbo_BidsReceivedDetail].[BidAmount])-Min([dbo_BidsReceivedDetail].[BidAmount])))) AS Range
FROM dbo_Project INNER JOIN dbo_BidsReceivedDetail ON dbo_Project.ProjectCode = dbo_BidsReceivedDetail.ProjectCode
GROUP BY dbo_Project.StatusCode, dbo_BidsReceivedDetail.TradeCode, dbo_BidsReceivedDetail.ProjectCode, dbo_BidsReceivedDetail.AlternateBidNumber
HAVING (((dbo_Project.StatusCode)="AWD" Or (dbo_Project.StatusCode)="COM")
AND ((dbo_BidsReceivedDetail.AlternateBidNumber)=0))
ORDER BY dbo_BidsReceivedDetail.TradeCode;
But then I realized that bids can be places on different days and I need to only show the last day. I want to do this all in one query if possible.
I tried to group by Last(dbo_BidsReceivedDetail.BidDate) but apparently that can't be done.
Any Ideas?
Thanks!
Here is an example of the data I am getting this from, I want to use only the highlighted values to get the range of bid amount