Everyone, I have been asked to do something that is way over my head. Below is the SQL of a query that I currently have. I need to throw some more criteria in for the totals. I have two Fields: FirstShift & SecondShift. They are yes/no boxes. I need the query to give me the same totals as it does now but by FirstShift & Secondshift. I also then would need the grand totals for the day which of course would be a combination of the two shifts. To take it a step further one of The FaultCategory's is NoFault. I would like to know the percentage of WorkUnits for each shift and total that were NoFaults. I know you need to divde the number of NoFaults by the Total Number of WorkUnits per shift and then per day. Is this doable? I sure hope so. I have been given this as a challenge and am hoping someone out there can get me the answer.Thanks in advance.Select FaultCategory, Count(*) As [Faults/NoFaults]From WorkUnitsFaultsMainTBLWhere [TodaysDate] Between [Forms]![WorkUnitsFaultsMainFRM]![StartDateTxt] And [Forms]![WorkUnitsFaultsMainFRM]![EndDateTxt]Group By FaultCategoryUNION ALL Select 'Total Work Units', count([WorkUnit]) from (select distinct [WorkUnit] from WorkUnitsFaultsMainTBLWhere [TodaysDate] Between [Forms]![WorkUnitsFaultsMainFRM]![StartDateTxt] And [Forms]![WorkUnitsFaultsMainFRM]![EndDateTxt]);
Someone else provided the following SQL but it is not working. I get this error:The expression is typed incorrectly, or it is too complex to be evaluated. For example, a numerica expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables.Select 'Shift 1', FaultCategory, Count(*) As [Faults/NoFaults]From WorkUnitsFaultsMainTBLWhere [TodaysDate] Between [Forms]![WorkUnitsFaultsMainFRM]![StartDateTxt] And [Forms]![WorkUnitsFaultsMainFRM]![EndDateTxt]and FirstShift = "yes"Group By FaultCategoryunion all Select 'Shift 2', FaultCategory, Count(*) As [Faults/NoFaults]From WorkUnitsFaultsMainTBLWhere [TodaysDate] Between [Forms]![WorkUnitsFaultsMainFRM]![StartDateTxt] And [Forms]![WorkUnitsFaultsMainFRM]![EndDateTxt]and SecondShift = "yes"Group By FaultCategoryUNION ALL Select '','Total Work Units', count([WorkUnit]) from (select distinct [WorkUnit] from WorkUnitsFaultsMainTBLWhere [TodaysDate] Between [Forms]![WorkUnitsFaultsMainFRM]![StartDateTxt] And [Forms]![WorkUnitsFaultsMainFRM]![EndDateTxt]);