I am working on database that has a main table, tblAllRecords, where all of the data that is of interest to me is stored. The table is related to the other tables in the database via ID fields. Right now, I have the following query which joins tblEquipment and tblAllRecords and counts the total number instances where the value of AREquipment is equal to tblEquipment.EquipmentID.
Code: Select all
SELECT tblEquipment.EquipmentID, tblEquipment.Equipment, Count(tblAllRecords.AREquipment) AS CountOfAREquipment, (select Count(ARID) From tblAllRecords) AS Total, [CountOfAREquipment]/[Total] AS PercentOfAREquipment
FROM tblEquipment LEFT JOIN tblAllRecords ON tblEquipment.EquipmentID = tblAllRecords.AREquipment
GROUP BY tblEquipment.EquipmentID, tblEquipment.Equipment;
Code: Select all
SELECT Count(ARDate) as CountDate
FROM (SELECT DISTINCT ARDate FROM tblAllRecords)