Question : NZ fuction does not work properly

need your help!!!!!!!!
Every morning user must clock in in the system. Clock In time recorded as Time.
it looks like:
Name           Time
Person B      9/2/2008 6:38 AM
Person A      9/2/2008 8:10 AM
Person B      9/3/2008 6:41 AM
Of course, calendar month has weekends(WE), holidays(H), and also the person might be just off
When you are clock in- the status should be 1, when you are not clock in - you are off and the status  0
i can make the cross tab query and see the results

here is my table and the results of my query:
Name      Time                           Count      Day
Person A      9/2/2008 8:10:03 AM      1      02
Person B      9/2/2008 6:38:04 AM      1      02
Person B      9/3/2008 6:41:57 AM      1      03
Person A      9/3/2008 7:57:26 AM      1      03
Person B      9/4/2008 6:42:10 AM      1      04
Person A      9/4/2008 7:46:48 AM      1      04
Person B      9/5/2008 6:37:18 AM      1      05
On september 1 it was a  holiday, that is why there is no any records for the 01,
on september 05 the Person A was off, that is why his time not in the table
my query2:
SELECT Test.Name, Test.Time, Count(nz([ID],0)) AS Count, Format([Time],'dd') AS [Day]
FROM Test
GROUP BY Test.Name, Test.Time, Format([Time],'dd');

My goal to see the results in crosstab format:
TRANSFORM Count(Query2.Count) AS Count
SELECT Query2.Name, Count(Query2.Count) AS Total
FROM Query2
GROUP BY Query2.Name
PIVOT Format([Time],"dd");
that is the result:
Name      Total      02      03      04      05
Person A      19      1      1      1      
Person B      19      1      1      1      1

My query is not working, it gives me a blank instead of 0 for person A for 05,

also how to make to see also 01 with H value in

Answer : NZ fuction does not work properly

Here you go 2 new queries  and an update query2

query3 and the function remain the same.

Should get you want you want.  

Keep in mind, this assumes you are not going to cross months when you run the date range and it only counts a person once per day, even if there are more than on log-ins per person per day.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
Query2_1
SELECT Test.Name, "H" AS cnt, Format([Holidaydate],'dd') AS [Day]
FROM Holidays, Test
GROUP BY Test.Name, "H", Format([Holidaydate],'dd');
 
Query2_2
SELECT Test.Name, "W" AS Cnt, Format([WeekendDate],'dd') AS [Day]
FROM tblWeekendDates, Test
GROUP BY Test.Name, "W", Format([WeekendDate],'dd');
 
Query2
SELECT Test.Name, Count(nz([Name],0)) AS Cnt, Format([Time],'dd') AS [Day]
FROM Test
GROUP BY Test.Name, Format([Time],'dd'), addweekenddates(#9/1/08#,#9/30/08#)
UNION 
SELECT Query2_1.Name, Query2_1.cnt, Query2_1.Day
FROM Query2_1 LEFT JOIN Test ON (Query2_1.Day = format(Test.Time,"DD")) AND (Query2_1.Name = Test.Name)
WHERE (((Test.Name) Is Null))
UNION 
SELECT Query2_2.Name, Query2_2.Cnt, Query2_2.Day
FROM Query2_2 LEFT JOIN Test ON (Query2_2.Day = format(Test.Time,"DD")) AND (Query2_2.Name = Test.Name)
WHERE (((Test.Name) Is Null));
Open in New Window Select All
Random Solutions  
 
programming4us programming4us