Question : Please correct query

The table has 7 fields:
CodeValue      ---like category (should be grouped by)
DateCompl1      first day out of three
DateCompl2      second day out of three
DateCompl3      third day out of three  
Time1               time in minutes  spend for a first day
Time2                time in minutes  spend for a sect day
Time3                time in minutes  spend for a lastt day

you can work only for two days or even one day only, in this case TIme for third day is O or for sec and third is 0
i need to sum all those time grouped by CodeValue for yesterday, 12/9/2009

so the results should be based on actual table:
DMS                           62
Non Source Codes      1
Source Codes      60
Capitations                            182
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
CodeValue	DateCompl1	DateCompl2	DateCompl3	Time1	Time2	Time3
C	5/29/2009			105	0	0
DMS	12/9/2009			62	0	0
NSC	8/6/2009			60	0	0
SC	6/15/2009			57	0	0
NSC	12/9/2009			1	0	0
SC	6/30/2009			63	0	0
SC	6/30/2009			45	0	0
NSC	6/30/2009			120	0	0
SC	12/9/2009			60	0	0
SC	8/3/2009	12/9/2009		120	60	0
C	8/3/2009	8/3/2009	12/9/2009	59	60	62
C	8/6/2009	8/6/2009	12/9/2009	60	121	120
 
my query  does not return anything (:
SELECT a.CodeValue, Sum(a.Complete) AS Total
FROM [SELECT 
	CodeValue, 
	nz(DateCompl3, nz(DateCompl2, DateCompl1)) as DateCompl, iif(Time3=0, iif(Time2=0, Time1,Time2), Time3) as Complete  
 
FROM QueryCount2a 
 
]. AS a
WHERE (((a.DateCompl)=Format(Now()-1,"mm/dd/yyyy")))
GROUP BY a.CodeValue;

Answer : Please correct query

You mean like this?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
SELECT   
rm.CodeValue,   
(select min(DateRec) from QueryCount2 where CodeValue=rm.CodeValue and DayCompleted is null) AS [Oldest Uncompleted],  
nz(DateDiff("d",(select min(DateRec) from QueryCount2 where CodeValue=rm.CodeValue and DayCompleted is  null),Now()-1),0) AS [Days Diff],  
nz((select sum(CountApp) from  QueryCount2 where CodeValue=rm.CodeValue and DateRec=format(now-1,"mm/dd/yyyy")),0 ) as [Incoming Today], 
(select sum(a.Complete) as Total from ( 
SELECT DateRec, CodeValue, nz(DateCompl3, nz(DateCompl2, DateCompl1)) as DateCompl, iif(Day3=0, iif(Day2=0, Day1,Day2), Day3) as Complete  
FROM QueryCount2) a where a.DateCompl = date() and a.CodeValue = rm.CodeValue) as [Completed],
(SELECT Format((Sum(a.Complete)/60),"0.00" ) AS Total  
FROM  (SELECT CodeValue,   
nz(DateCompl3, nz(DateCompl2, DateCompl1)) as DateCompl, iif(Time3=0, iif(Time2=0, Time1,Time2), Time3) as Complete    
FROM QueryCount2a   )  a WHERE a.DateCompl=date()-1 a.CodeValue = rm.CodeValue) as [yournewcolumnname]
FROM   
QueryCount2 AS rm  
GROUP BY rm.CodeValue;
Random Solutions  
 
programming4us programming4us