Calculations within queries

Novice

Board Regular
Joined
Mar 18, 2003
Messages
53
Hi,
I have built a query to count a number of pass/fail occurences against a user. This query is running but is only counting users who have both pass and fail occurences, it is not tracking those that only have pass only or fail only.
I do not have any criteria in the main query in the pass/fail select field. I thought this would capture everything. I can count all passes and all fails in two seperate queries but cannot capture this information in one query.

I tried a crosstab query but it won't allow enough fields to be entered.
Any ideas?
Thanks
Novice :oops:
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hullo. Please post your SQL, and we'll take a look. Shooting from the hip, my guess is to try a form of this equation:
Code:
Iif(Not IsNull([Result]),Iif([Result]="Pass" OR [Result]="pass", "Passed","Failed"),"No Value")

That will check if there is a value in Results, then test possible entries in that field.

HTH (y)

P
 
Upvote 0
Hi,
The SQL is as follows.
Thks
Novice

SELECT q_Pass_By_Qtr.Inspection_Area, T_Builders.[Builders Name], [Units_Passed]/([Units_Passed]+[Units_Failed]) AS Pass_Rate, q_Pass_By_Qtr.Units_Passed, q_Fail_By_Qtr.Units_Failed, [Units_Passed]+[Units_Failed] AS Total, q_Pass_By_Qtr.Quarter, q_Pass_By_Qtr.Year
FROM (T_Builders LEFT JOIN q_Pass_By_Qtr ON T_Builders.[Builders Name] = q_Pass_By_Qtr.Builder) LEFT JOIN q_Fail_By_Qtr ON T_Builders.[Builders Name] = q_Fail_By_Qtr.Builder
GROUP BY q_Pass_By_Qtr.Inspection_Area, T_Builders.[Builders Name], [Units_Passed]/([Units_Passed]+[Units_Failed]), q_Pass_By_Qtr.Units_Passed, q_Fail_By_Qtr.Units_Failed, [Units_Passed]+[Units_Failed], q_Pass_By_Qtr.Quarter, q_Pass_By_Qtr.Year
HAVING ((([Units_Passed]+[Units_Failed])>0))
ORDER BY [Units_Passed]/([Units_Passed]+[Units_Failed]) DESC , q_Pass_By_Qtr.Units_Passed, q_Fail_By_Qtr.Units_Failed DESC , [Units_Passed]+[Units_Failed] DESC;
 
Upvote 0

Forum statistics

Threads
1,221,543
Messages
6,160,421
Members
451,644
Latest member
hglymph

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top