gammele Posted November 24, 2011 Share Posted November 24, 2011 Hi there programmers, I am trying to get the avarage score for a criterium out of the database. The system is used to give grades to a meeting. My database structure is like this: #Results# Result_id Result_overall_percentage #criteriumresult# Criteriumresult_id Criteriumresult_link_id (refers to result_id) Criteriumresult_criterium_id (refers to criterium_id) Criteriumresult_percentage #criterium Criterium_id Criterium_tekst For example: 1 - The employees are well prepared 2 - There was no interruption What i would like to do, is write a query, which collects the avarage score of ID's. //splittetResultIDs = multiple selections $SelectQuery = mysql_query(" SELECT * FROM criteriumresult WHERE Criteriumresult_link_id IN(".$splittetResultIDs.") ") or die (mysql_error()); I get a lot of results, but i would like to filter unique criteria, and only list them as unique items and with an avarege score. How can i do this? Quote Link to comment Share on other sites More sharing options...
fenway Posted November 25, 2011 Share Posted November 25, 2011 What's a Criterium? You mean criterion? Quote Link to comment Share on other sites More sharing options...
Nodral Posted November 25, 2011 Share Posted November 25, 2011 You need to be slightly clearer on what you want. There is an AVG function within MYSQL which will do what you want and you can still have a WHERE clause on it. Eg SELECT AVG(Result_overall_percentage) as Average FROM Results WHERE ........................ This will give you a return called 'Average' depending on the conditions you specify in the WHERE clause Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.