Question : Select query

I have a database Test and table QueryCount2
I need  help with single query which retrives following:
Please look at word attachemnt for better explanation
every record has :
ID                           1
DateRec              9/25/2009
CodeValue              SC
CountApp             100------------total documents needs to be processed
Day1             80  processed on first day 9/25/2009
Day2                    15 processed on sec day  09/26/2009
Day3             5  processed on third day 09/30/2009
TotalPro             100 sum of three days processed (record completed )
DateCompl1             9/25/2009
DateCompl2          09/26/2009
DateCompl3             09/30/2009  and this is date of completion
DayCompleted     09/30/2009
you can process everything for one day and the DateCOmp1 is DayCompleted
or on second and and the DateCOmp2 is DayCompleted
 as you can see in excel file there is activity for different days, i need to capture all activity for a particluar day
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
I need to get all information for a particular day, let say it
for 09-Dec-09:
all counts for 09-Dec-09
in example it will be:
ValueCode Count
DMS	5
SC	99
DMS	3
 and after grouping  by Value Code it should be 
DMS	8
SC	99

Answer : Select query

So you mean adding another column, right? try this
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
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]
 
FROM  
QueryCount2 AS rm 
GROUP BY rm.CodeValue;
Random Solutions  
 
programming4us programming4us