T
Tony White
Hello
I have a query that counts the number of employees that were hired and left
within a certain date range. I take the answers from each query and append
the results to a table. When no employees were hired or no employees left, I
get null values. I tried to add Nz at the beginning of the SQL but I still
get the "no records" view (just the grey box listing the field name). I think
I am using the Nz function in the wrong place since the SQL does not bomb
out. Here is my code:
qryCountofTermsByPosition
SELECT Nz(Count(tbl_Employee.eNumberID),0) AS CountOfeNumberID
FROM ((tbl_Market INNER JOIN tbl_Group ON tbl_Market.marketID =
tbl_Group.marketID) INNER JOIN (tbl_Region INNER JOIN tbl_Department ON
tbl_Region.regionID = tbl_Department.regionID) ON tbl_Group.groupID =
tbl_Region.groupID) INNER JOIN ((tbl_Termination INNER JOIN tbl_Employee ON
tbl_Termination.termReason = tbl_Employee.termReason) INNER JOIN (tbl_Job
INNER JOIN tbl_EmployeeJobs ON tbl_Job.jobCodeID =
tbl_EmployeeJobs.jobCodeID) ON tbl_Employee.eNumberID =
tbl_EmployeeJobs.eNumberID) ON tbl_Department.rcID = tbl_EmployeeJobs.rcID
GROUP BY tbl_Employee.recentHireDate, tbl_Employee.termDate,
tbl_Termination.termType, tbl_Employee.resi, tbl_EmployeeJobs.Category,
tbl_Job.revisedJobTitle, tbl_Market.marketID, tbl_EmployeeJobs.schedHrs
HAVING (((tbl_Employee.recentHireDate)>=#12/1/2003# And
(tbl_Employee.recentHireDate)<=#12/31/2003#) AND
((tbl_Employee.termDate)>=#12/1/2003# And
(tbl_Employee.termDate)<=#1/31/2004#) AND ((tbl_Termination.termType)='V')
AND ((tbl_EmployeeJobs.Category)='P' Or (tbl_EmployeeJobs.Category)='Q' Or
(tbl_EmployeeJobs.Category)='F') AND ((tbl_Job.revisedJobTitle)='Teller') AND
((tbl_Market.marketID)='PHL') AND ((tbl_EmployeeJobs.schedHrs)>30)) OR
(((tbl_Employee.recentHireDate)>=#12/1/2003# And
(tbl_Employee.recentHireDate)<=#12/31/2003#) AND
((tbl_Employee.termDate)>=#12/1/2003# And
(tbl_Employee.termDate)<=#1/31/2004#) AND ((tbl_Employee.resi) Is Not Null)
AND ((tbl_EmployeeJobs.Category)='P' Or (tbl_EmployeeJobs.Category)='Q' Or
(tbl_EmployeeJobs.Category)='F') AND ((tbl_Job.revisedJobTitle)='Teller') AND
((tbl_Market.marketID)='PHL') AND ((tbl_EmployeeJobs.schedHrs)>30));
As a work around, after I append all the records to the table, I run a
subroutine that updates all null values to zero.
Thank you for your help!!!
Tony
I have a query that counts the number of employees that were hired and left
within a certain date range. I take the answers from each query and append
the results to a table. When no employees were hired or no employees left, I
get null values. I tried to add Nz at the beginning of the SQL but I still
get the "no records" view (just the grey box listing the field name). I think
I am using the Nz function in the wrong place since the SQL does not bomb
out. Here is my code:
qryCountofTermsByPosition
SELECT Nz(Count(tbl_Employee.eNumberID),0) AS CountOfeNumberID
FROM ((tbl_Market INNER JOIN tbl_Group ON tbl_Market.marketID =
tbl_Group.marketID) INNER JOIN (tbl_Region INNER JOIN tbl_Department ON
tbl_Region.regionID = tbl_Department.regionID) ON tbl_Group.groupID =
tbl_Region.groupID) INNER JOIN ((tbl_Termination INNER JOIN tbl_Employee ON
tbl_Termination.termReason = tbl_Employee.termReason) INNER JOIN (tbl_Job
INNER JOIN tbl_EmployeeJobs ON tbl_Job.jobCodeID =
tbl_EmployeeJobs.jobCodeID) ON tbl_Employee.eNumberID =
tbl_EmployeeJobs.eNumberID) ON tbl_Department.rcID = tbl_EmployeeJobs.rcID
GROUP BY tbl_Employee.recentHireDate, tbl_Employee.termDate,
tbl_Termination.termType, tbl_Employee.resi, tbl_EmployeeJobs.Category,
tbl_Job.revisedJobTitle, tbl_Market.marketID, tbl_EmployeeJobs.schedHrs
HAVING (((tbl_Employee.recentHireDate)>=#12/1/2003# And
(tbl_Employee.recentHireDate)<=#12/31/2003#) AND
((tbl_Employee.termDate)>=#12/1/2003# And
(tbl_Employee.termDate)<=#1/31/2004#) AND ((tbl_Termination.termType)='V')
AND ((tbl_EmployeeJobs.Category)='P' Or (tbl_EmployeeJobs.Category)='Q' Or
(tbl_EmployeeJobs.Category)='F') AND ((tbl_Job.revisedJobTitle)='Teller') AND
((tbl_Market.marketID)='PHL') AND ((tbl_EmployeeJobs.schedHrs)>30)) OR
(((tbl_Employee.recentHireDate)>=#12/1/2003# And
(tbl_Employee.recentHireDate)<=#12/31/2003#) AND
((tbl_Employee.termDate)>=#12/1/2003# And
(tbl_Employee.termDate)<=#1/31/2004#) AND ((tbl_Employee.resi) Is Not Null)
AND ((tbl_EmployeeJobs.Category)='P' Or (tbl_EmployeeJobs.Category)='Q' Or
(tbl_EmployeeJobs.Category)='F') AND ((tbl_Job.revisedJobTitle)='Teller') AND
((tbl_Market.marketID)='PHL') AND ((tbl_EmployeeJobs.schedHrs)>30));
As a work around, after I append all the records to the table, I run a
subroutine that updates all null values to zero.
Thank you for your help!!!
Tony