Microsoft
Software
Hardware
Network
Question : Average of numbers - count only records with complete data
I have a DB with a table that contains the core data (name, dept, RateJournal, RateBooks....). I have code written which will average the data for each field. The problem is some of the records do not have data for the "Rate.." fields. I want to count and average only those records for fields which have a number greater than 0. Not sure how to delete the incomplete records. Following is working code, but it is counting all records and then averaging. I am new to this type of calculations, please advise. Thanks.
<%
'Number of records with priority rankings
sqlCount = "SELECT count(*) AS records FROM tblClinicians "
Set objCount = objConn.Execute(sqlCount)
sqlRank = "SELECT ROUND(AVG(tblClinicians.Ra
teJournal)
, 2) AS RateJournal, " & _
"ROUND(AVG(tblClinicians.R
ateBooks),
2) AS RateBooks, " & _
"ROUND(AVG(tblClinicians.R
ateDatabas
e), 2) AS RateDatabase, " & _
"ROUND(AVG(tblClinicians.R
atePOC), 2) AS RatePOC, " & _
"ROUND(AVG(tblClinicians.R
ateMultipl
e), 2) AS RateMultiple, " & _
"ROUND(AVG(tblClinicians.R
ateOther),
2) AS RateOther " & _
"FROM tblClinicians "
Set objRank = objConn.Execute(sqlRank)
%>
<%=title%>
<%=title%>
Total number of evaluations completed (includes ONLY those responses where rankings were completed):
Ranking: importance of the type of online resources (#1 is first/top priority -
#2 is second/2nd priority)
Journals: <%=objRank("RateJournal")%
>
Books: <%=objRank("RateBooks")%>
Database: <%=objRank("RateDatabase")
%>
Point of Care Products: <%=objRank("RatePOC")%>
Multiple Resources in One: <%=objRank("RateMultiple")
%>
Other: <%=objRank("RateOther")%>
Answer : Average of numbers - count only records with complete data
re: "do not have data for the "Rate.." fields"
So, these fields probably allow NULL.
How about adding:
WHERE tblClinicians.RateJournal IS NOT NULL
AND tblClinicians.RateBooks IS NOT NULL
AND etc.
Random Solutions
Revoked Certificates publication issue
Unable to connect to SQL Server 05 Express
HTTP_500 Error in SBS 2003 Exchange ActiveSync - FolerSync Step
end error beeping in windows web server 2008
Access TRIM Field Name
I have downloaded the zip of windows 7 for 30 days evaluation version. but now i'm trying to write it to a DVD to make it to boot windows 7 to install in my laptop. i copied the files using nero 8.
Viewing print output from a Stored Procedure in SQL Server Management Studio
Put Two Case conditions in same select statement - SQL Server 2005
Informix ODBC 64 bit drivers for Win 2003 server
Text control on Access form - double click highlights word