[thelist] SQL Query Help

Michael Pack michaelpack at wvdhhr.org
Wed Mar 1 10:40:26 CST 2006


Hi all, I'm stuck a bit and drawing blanks.

My query is...

SELECT     COUNT(dbo.tbl_audit.update_stamp) AS ComplianceData,
dbo.tbl_audit.fkFacilityId, dbo.tbl_facility.txtAgencyName,
dbo.tbl_facility.name, 
                      dbo.tbl_facility.id
FROM         dbo.tbl_audit INNER JOIN
                      dbo.tbl_facility ON dbo.tbl_audit.fkFacilityId =
dbo.tbl_facility.id
WHERE     (dbo.tbl_audit.update_stamp >= '20060201') AND
(dbo.tbl_audit.update_stamp < '20060228') AND 
                      (dbo.tbl_audit.update_stamp -
CAST(FLOOR(CAST(dbo.tbl_audit.update_stamp AS float)) AS datetime)
BETWEEN '00:00:00:000' AND '10:00:01:000')
GROUP BY dbo.tbl_audit.fkFacilityId, dbo.tbl_facility.txtAgencyName,
dbo.tbl_facility.name, dbo.tbl_facility.id

This returns the records starting at 1, showing me the "Agencies" that
meet the criteria. How would grab and return the records that have a 0
COUNT within the same query? I need to show the "Agencies" that have not
met the criteria as well.

TIA





More information about the thelist mailing list