{"id":1101,"date":"2013-10-18T07:08:55","date_gmt":"2013-10-18T07:08:55","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=1101"},"modified":"2022-02-17T07:14:03","modified_gmt":"2022-02-17T07:14:03","slug":"maths-based-results","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/mysql\/queries\/select\/maths-based-results","title":{"rendered":"Maths based results"},"content":{"rendered":"<p>\n<span style=\"color:#FF0000;\"><em><strong>This is PHP4 Code!<\/strong><\/em><\/span>\n<\/p>\n<h4>\nGet Number of Results<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n \t$query1 = @mysql_query(&quot;SELECT COUNT(*) FROM some_table WHERE some_column != 1&quot;);\r\n  $number_of_rows = @mysql_fetch_array($query1);\r\n\t$number_of_rows = $number_of_rows[0];\r\n\techo &quot;This many: $number_of_rows&quot;;\r\n<\/code><\/pre>\n<p>\n&nbsp;\n<\/p>\n<h4>\n<span style=\"font-size: 16px;\">Results B<\/span><span style=\"font-size: 16px;\">ased O<\/span><span style=\"font-size: 16px;\">n A<\/span><span style=\"font-size: 16px;\">n A<\/span><span style=\"font-size: 16px;\">verage S<\/span><span style=\"font-size: 16px;\">core Calcul<\/span><span style=\"font-size: 16px;\">ation<\/span><br \/>\n<\/h4>\n<pre>\r\n<code>\r\n$query1 = @mysql_query(&quot;SELECT \r\n\t\tuniversity_name, \r\n\t\tCONVERT((score \/ games_played), UNSIGNED INTEGER) as ave_score\r\n\tFROM tbl_universities \r\n\tORDER BY ave_score DESC, university_name ASC&quot;);\r\n\t\/\/CONVERT only needed if you want the values converted from floats to integers before the sort, use &quot;(score \/ games_played) as ave_score&quot; otherwise\r\n$count = mysql_num_rows($query1);\r\nwhile ($result1 = @mysql_fetch_array($query1))    \/\/Get each row returned\r\n{\r\n\t$university_name = $result1['university_name'];\r\n\t$ave_score = intval($result1['ave_score']);\t\t\/\/intval needed as zero results will come in as null\r\n<\/code><\/pre>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is PHP4 Code! Get Number of Results $query1 = @mysql_query(&quot;SELECT COUNT(*) FROM some_table WHERE some_column != 1&quot;); $number_of_rows = @mysql_fetch_array($query1); $number_of_rows = $number_of_rows[0]; echo &quot;This many: $number_of_rows&quot;; &nbsp; Results Based On An Average Score Calculation $query1 = @mysql_query(&quot;SELECT university_name, CONVERT((score \/ games_played), UNSIGNED INTEGER) as ave_score FROM tbl_universities ORDER BY ave_score DESC, university_name ASC&quot;); [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64],"tags":[],"class_list":["post-1101","post","type-post","status-publish","format-standard","hentry","category-select"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/1101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=1101"}],"version-history":[{"count":4,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/1101\/revisions"}],"predecessor-version":[{"id":1835,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/1101\/revisions\/1835"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=1101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=1101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=1101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}