It Looks complicated to me but here it is
SELECT MaleReport1.[SHED #], MaleReport1.[MALE NUMBER],
Count(MaleReport1.[MALE NUMBER]) AS [CountOfMALE NUMBER], [CountOfMALE
NUMBER]-[Expr9] AS Mates, Sum(MaleReport1.KITS) AS SumOfKITS,
[SumOfKITS]-[Expr10] AS KITS, IIf([Mates]<=0,0,[KITS]/[Mates]) AS [Kit
Avg],
Sum(MaleReport1.[Kits Survived]) AS [SumOfKits Survived], [SumOfKits
Survived]-([Expr11]+[Expr12]) AS [Kits Survived], IIf([Mates]<=0,0,[Kits
Survived]/[Mates]) AS [Kits Sur Avg], Sum(MaleReport1.[FEMALE KITS]) AS
[SumOfFEMALE KITS], [SumOfFEMALE KITS]-[Expr11] AS [Female Kits],
IIf([Mates]<=0,0,[Female Kits]/[Mates]) AS [Female Kit Avg],
Sum(MaleReport1.[MALE KITS]) AS [SumOfMALE KITS], [SumOfMALE
KITS]-[Expr12]
AS [Male Kits], IIf([Mates]<=0,0,[Male Kits]/[Mates]) AS [Male Kit Avg],
Sum(MaleReport1.Wg_grms) AS SumOfWg_grms, [SumOfWg_grms]-[Expr13] AS [Wg
gms], IIf(([Mates]-[Expr7])<=0,0,[Wg gms]/([Mates]-[Expr7])) AS [Avg Wg
gms], Sum(IIf([MaleReport1]![3rd MATING] Is Not Null And
[MaleReport1]![4TH
MATING] Is Not Null And [MaleReport1]![4TH MATING]=[MaleReport1]![MALE
NUMBER] And [MaleReport1]![MISSED]=True,1,0))+Sum(IIf([MaleReport1]![2nd
MATING] Is Not Null And [MaleReport1]![3rd MATING]=[MaleReport1]![MALE
NUMBER] And [MaleReport1]![4TH MATING] Is Null And
[MaleReport1]![MISSED]=True,1,0))+Sum(IIf([MaleReport1]![1st MATING] Is
Not
Null And [MaleReport1]![2nd MATING]=[MaleReport1]![MALE NUMBER] And
[MaleReport1]![3rd MATING] Is Null And
[MaleReport1]![MISSED]=True,1,0))+Sum(IIf([MaleReport1]![1st MATING] Is
Not
Null And [MaleReport1]![1st MATING]=[MaleReport1]![MALE NUMBER] And
[MaleReport1]![2nd MATING] Is Null And [MaleReport1]![MISSED]=True,1,0))
AS
Misses, Sum(IIf([MaleReport1]![Kits] Is Null And [MaleReport1]![WHELPING
DATE] Is Not Null,1,0)) AS Expr7, Sum(IIf([MaleReport1]![1st
MATING]=[MaleReport1]![MALE NUMBER],1,0))+Sum(IIf([MaleReport1]![2nd
MATING]=[MaleReport1]![MALE NUMBER],1,0))+Sum(IIf([MaleReport1]![3rd
MATING]=[MaleReport1]![MALE NUMBER],1,0))+Sum(IIf([MaleReport1]![4TH
MATING]=[MaleReport1]![MALE NUMBER],1,0)) AS Matings,
Sum(IIf([MaleReport1]![3rd MATING] Is Not Null And [MaleReport1]![4TH
MATING] Is Not Null And [MaleReport1]![4TH MATING]<>[MaleReport1]![MALE
NUMBER],1,0))+Sum(IIf([MaleReport1]![2nd MATING] Is Not Null And
[MaleReport1]![3rd MATING]<>[MaleReport1]![MALE NUMBER] And
[MaleReport1]![4TH MATING] Is Null,1,0))+Sum(IIf([MaleReport1]![1st
MATING]
Is Not Null And [MaleReport1]![2nd MATING]<>[MaleReport1]![MALE NUMBER]
And
[MaleReport1]![3rd MATING] Is Null,1,0))+Sum(IIf([MaleReport1]![1st
MATING]
Is Not Null And [MaleReport1]![1st MATING]<>[MaleReport1]![MALE NUMBER]
And
[MaleReport1]![2nd MATING] Is Null,1,0)) AS Expr9,
Sum(IIf([MaleReport1]![3rd MATING] Is Not Null And [MaleReport1]![4TH
MATING] Is Not Null And [MaleReport1]![4TH MATING]<>[MaleReport1]![MALE
NUMBER],[MaleReport1]![KITS],0))+Sum(IIf([MaleReport1]![2nd MATING] Is Not
Null And [MaleReport1]![3rd MATING]<>[MaleReport1]![MALE NUMBER] And
[MaleReport1]![4TH MATING] Is
Null,[MaleReport1]![KITS],0))+Sum(IIf([MaleReport1]![1st MATING] Is Not
Null
And [MaleReport1]![2nd MATING]<>[MaleReport1]![MALE NUMBER] And
[MaleReport1]![3rd MATING] Is
Null,[MaleReport1]![KITS],0))+Sum(IIf([MaleReport1]![1st MATING] Is Not
Null
And [MaleReport1]![1st MATING]<>[MaleReport1]![MALE NUMBER] And
[MaleReport1]![2nd MATING] Is Null,[MaleReport1]![KITS],0)) AS Expr10,
Sum(IIf([MaleReport1]![3rd MATING] Is Not Null And [MaleReport1]![4TH
MATING] Is Not Null And [MaleReport1]![4TH MATING]<>[MaleReport1]![MALE
NUMBER],[MaleReport1]![FEMALE KITS],0))+Sum(IIf([MaleReport1]![2nd MATING]
Is Not Null And [MaleReport1]![3rd MATING]<>[MaleReport1]![MALE NUMBER]
And
[MaleReport1]![4TH MATING] Is Null,[MaleReport1]![FEMALE
KITS],0))+Sum(IIf([MaleReport1]![1st MATING] Is Not Null And
[MaleReport1]![2nd MATING]<>[MaleReport1]![MALE NUMBER] And
[MaleReport1]![3rd MATING] Is Null,[MaleReport1]![FEMALE
KITS],0))+Sum(IIf([MaleReport1]![1st MATING] Is Not Null And
[MaleReport1]![1st MATING]<>[MaleReport1]![MALE NUMBER] And
[MaleReport1]![2nd MATING] Is Null,[MaleReport1]![FEMALE KITS],0)) AS
Expr11, Sum(IIf([MaleReport1]![3rd MATING] Is Not Null And
[MaleReport1]![4TH MATING] Is Not Null And [MaleReport1]![4TH
MATING]<>[MaleReport1]![MALE NUMBER],[MaleReport1]![MALE
KITS],0))+Sum(IIf([MaleReport1]![2nd MATING] Is Not Null And
[MaleReport1]![3rd MATING]<>[MaleReport1]![MALE NUMBER] And
[MaleReport1]![4TH MATING] Is Null,[MaleReport1]![MALE
KITS],0))+Sum(IIf([MaleReport1]![1st MATING] Is Not Null And
[MaleReport1]![2nd MATING]<>[MaleReport1]![MALE NUMBER] And
[MaleReport1]![3rd MATING] Is Null,[MaleReport1]![MALE
KITS],0))+Sum(IIf([MaleReport1]![1st MATING] Is Not Null And
[MaleReport1]![1st MATING]<>[MaleReport1]![MALE NUMBER] And
[MaleReport1]![2nd MATING] Is Null,[MaleReport1]![MALE KITS],0)) AS
Expr12,
Sum(IIf([MaleReport1]![3rd MATING] Is Not Null And [MaleReport1]![4TH
MATING] Is Not Null And [MaleReport1]![4TH MATING]<>[MaleReport1]![MALE
NUMBER],[MaleReport1]![Wg_grms],0))+Sum(IIf([MaleReport1]![2nd MATING] Is
Not Null And [MaleReport1]![3rd MATING]<>[MaleReport1]![MALE NUMBER] And
[MaleReport1]![4TH MATING] Is
Null,[MaleReport1]![Wg_grms],0))+Sum(IIf([MaleReport1]![1st MATING] Is Not
Null And [MaleReport1]![2nd MATING]<>[MaleReport1]![MALE NUMBER] And
[MaleReport1]![3rd MATING] Is
Null,[MaleReport1]![Wg_grms],0))+Sum(IIf([MaleReport1]![1st MATING] Is Not
Null And [MaleReport1]![1st MATING]<>[MaleReport1]![MALE NUMBER] And
[MaleReport1]![2nd MATING] Is Null,[MaleReport1]![Wg_grms],0)) AS Expr13,
Sum(IIf([MaleReport1]![WHELPING DATE] Is Not Null,1,0)) AS [Total Whelped
Females], Sum(IIf([MaleReport1]![FEMALE #] Is Not Null,1,0)) AS [Total
Females]
FROM MaleReport1
GROUP BY MaleReport1.[SHED #], MaleReport1.[MALE NUMBER]
ORDER BY MaleReport1.[MALE NUMBER];
It is based off another Query
Thanks Blair
OfficeDev18 via AccessMonster.com said:
Blair,
What's the total SQL look like?
Sam
Blair wrote:
I have this expression
Total Whelped Females: Sum(IIf([MaleReport1]![WHELPING DATE] Is Not
Null,1,0))
It gives me the sum for each record, which there are 54 records and the
total of the sums would be 337. How do I get this to total? When I drag
field into report I get 9 which is the sum of the first row, I want 337
Thanks Blair