L
Liam Murphy
I have created a database to track issues with paperwork, and use a yes/no block to identify whether an issue exists for each page. I have finally been successful in running a query that counts each instance of each particular error, by date, but since I am using a yes/no, a yes is, by default, a -1, and when it sums them, I get a negative number. I would like to display positive numbers, so I can export to excel and create a spreadsheet with just the numerical data, and perform various math functions from there. I will post the SQL so that it can be more easily pointed out what I need to fix. Each error type is it's own field, so there are a lot of fields, so it is a bit long. Thanks for any help.
SELECT DISTINCTROW Format$([Data_Entry_Tbl].[SurveyDate],'mmmm yyyy') AS [SurveyDate By Month], Data_Entry_Tbl.Boat, Sum(Data_Entry_Tbl.[SSDS Missing/Wrong Step No]) AS [Sum Of SSDS Missing/Wrong Step No], Sum(Data_Entry_Tbl.[SSDS No Initial And/Or Badge]) AS [Sum Of SSDS No Initial And/Or Badge], Sum(Data_Entry_Tbl.[SSDS Missing Page Number]) AS [Sum Of SSDS Missing Page Number], Sum(Data_Entry_Tbl.[SSDS Wrong Survey Results]) AS [Sum Of SSDS Wrong Survey Results], Sum(Data_Entry_Tbl.[SSDS Survey Results/Type Blank]) AS [Sum Of SSDS Survey Results/Type Blank], Sum(Data_Entry_Tbl.[SSDS Line Item Number Missing]) AS [Sum Of SSDS Line Item Number Missing], Sum(Data_Entry_Tbl.[Block 1 Blank]) AS [Sum Of Block 1 Blank], Sum(Data_Entry_Tbl.[Block 5 Inadequate Description]) AS [Sum Of Block 5 Inadequate Description], Sum(Data_Entry_Tbl.[Block 5 Incorrectly N/A'd]) AS [Sum Of Block 5 Incorrectly N/A'd], Sum(Data_Entry_Tbl.[Block 5 Blank or Not N/A]) AS [Sum Of Block 5 Blank or Not N/A], Sum(Data_Entry_Tbl.[Block 6 Not Checked/Wrong Checked]) AS [Sum Of Block 6 Not Checked/Wrong Checked], Sum(Data_Entry_Tbl.[Block 6 No/Wrong Procedure Name]) AS [Sum Of Block 6 No/Wrong Procedure Name], Sum(Data_Entry_Tbl.[Block 6 No/Wrong Step Number]) AS [Sum Of Block 6 No/Wrong Step Number], Sum(Data_Entry_Tbl.[Block 6 Inadequate Reason]) AS [Sum Of Block 6 Inadequate Reason], Sum(Data_Entry_Tbl.[Block 6 No Reason]) AS [Sum Of Block 6 No Reason], Sum(Data_Entry_Tbl.[Block 7 Incorrect Survey Instrument]) AS [Sum Of Block 7 Incorrect Survey Instrument], Sum(Data_Entry_Tbl.[Block 7 Missing Information]) AS [Sum Of Block 7 Missing Information], Sum(Data_Entry_Tbl.[Block 8 Not Checked]) AS [Sum Of Block 8 Not Checked], Sum(Data_Entry_Tbl.[Block 8 Not N/A]) AS [Sum Of Block 8 Not N/A], Sum(Data_Entry_Tbl.[Block 8 Missing/Incorrect Data]) AS [Sum Of Block 8 Missing/Incorrect Data], Count(*) AS [Count Of Data_Entry_Tbl]
FROM Data_Entry_Tbl
GROUP BY Format$([Data_Entry_Tbl].[SurveyDate],'mmmm yyyy'), Data_Entry_Tbl.Boat, Year([Data_Entry_Tbl].[SurveyDate])*12+DatePart('m',[Data_Entry_Tbl].[SurveyDate])-1;
SELECT DISTINCTROW Format$([Data_Entry_Tbl].[SurveyDate],'mmmm yyyy') AS [SurveyDate By Month], Data_Entry_Tbl.Boat, Sum(Data_Entry_Tbl.[SSDS Missing/Wrong Step No]) AS [Sum Of SSDS Missing/Wrong Step No], Sum(Data_Entry_Tbl.[SSDS No Initial And/Or Badge]) AS [Sum Of SSDS No Initial And/Or Badge], Sum(Data_Entry_Tbl.[SSDS Missing Page Number]) AS [Sum Of SSDS Missing Page Number], Sum(Data_Entry_Tbl.[SSDS Wrong Survey Results]) AS [Sum Of SSDS Wrong Survey Results], Sum(Data_Entry_Tbl.[SSDS Survey Results/Type Blank]) AS [Sum Of SSDS Survey Results/Type Blank], Sum(Data_Entry_Tbl.[SSDS Line Item Number Missing]) AS [Sum Of SSDS Line Item Number Missing], Sum(Data_Entry_Tbl.[Block 1 Blank]) AS [Sum Of Block 1 Blank], Sum(Data_Entry_Tbl.[Block 5 Inadequate Description]) AS [Sum Of Block 5 Inadequate Description], Sum(Data_Entry_Tbl.[Block 5 Incorrectly N/A'd]) AS [Sum Of Block 5 Incorrectly N/A'd], Sum(Data_Entry_Tbl.[Block 5 Blank or Not N/A]) AS [Sum Of Block 5 Blank or Not N/A], Sum(Data_Entry_Tbl.[Block 6 Not Checked/Wrong Checked]) AS [Sum Of Block 6 Not Checked/Wrong Checked], Sum(Data_Entry_Tbl.[Block 6 No/Wrong Procedure Name]) AS [Sum Of Block 6 No/Wrong Procedure Name], Sum(Data_Entry_Tbl.[Block 6 No/Wrong Step Number]) AS [Sum Of Block 6 No/Wrong Step Number], Sum(Data_Entry_Tbl.[Block 6 Inadequate Reason]) AS [Sum Of Block 6 Inadequate Reason], Sum(Data_Entry_Tbl.[Block 6 No Reason]) AS [Sum Of Block 6 No Reason], Sum(Data_Entry_Tbl.[Block 7 Incorrect Survey Instrument]) AS [Sum Of Block 7 Incorrect Survey Instrument], Sum(Data_Entry_Tbl.[Block 7 Missing Information]) AS [Sum Of Block 7 Missing Information], Sum(Data_Entry_Tbl.[Block 8 Not Checked]) AS [Sum Of Block 8 Not Checked], Sum(Data_Entry_Tbl.[Block 8 Not N/A]) AS [Sum Of Block 8 Not N/A], Sum(Data_Entry_Tbl.[Block 8 Missing/Incorrect Data]) AS [Sum Of Block 8 Missing/Incorrect Data], Count(*) AS [Count Of Data_Entry_Tbl]
FROM Data_Entry_Tbl
GROUP BY Format$([Data_Entry_Tbl].[SurveyDate],'mmmm yyyy'), Data_Entry_Tbl.Boat, Year([Data_Entry_Tbl].[SurveyDate])*12+DatePart('m',[Data_Entry_Tbl].[SurveyDate])-1;