Getting a ?DISTINCT? result
- From: "Tim" <tmiller@xxxxxxxxxxxx>
- Date: Thu, 7 Jul 2005 08:19:25 -0400
Tables ProjectAmount & ProjectBid both have Project ID in common, and both
tables can have many of these.
I need the SUM(ProjectAmount.Amount) for any related Project_ID in
ProjectBid WHERE Sum(ProjectBid.Awarded_Type) = 0.
I could also say: for any related Project_ID in ProjectBid WHERE All of the
ProjectBid.Awarded = False.
My problem is that no matter how I spin it, for these project the criteria,
the SUM that I'm after is being multiplied by the number of matching records
in ProjectBid. I thought that this is where DISTINCT came in, but it's not
working for and I'm not understanding why or what I can do about it.
This is what I'm using right now. It's Union'ed with others so I need to
only select these fields.
Hoping someone can enlighten me :) Thanks
SELECT A.PROJECT_ID, 0 Awarded, SUM(AMOUNT) UN_Awarded
FROM PROJECTAMOUNTS A
INNER JOIN PROJECTBID B
ON A.PROJECT_ID = B.PROJECT_ID
GROUP BY A.PROJECT_ID
HAVING SUM(B.AWARDED_TYPE)=0
.
- Follow-Ups:
- Re: Getting a ?DISTINCT? result
- From: MGFoster
- Re: Getting a ?DISTINCT? result
- Prev by Date: count weeks automatically
- Next by Date: Re: count weeks automatically
- Previous by thread: count weeks automatically
- Next by thread: Re: Getting a ?DISTINCT? result
- Index(es):