Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6898237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:16:14+00:00 2026-05-27T07:16:14+00:00

My webserver is running MySQL client version 5.1.56. My devserver is running MySQL client

  • 0

My webserver is running MySQL client version 5.1.56.

My devserver is running MySQL client version 5.0.7.

This query gives me the same result on both servers:

SELECT scenario_user_ratings.userid,
       AVG(scenario_user_ratings.rating)
FROM scenario_user_ratings
GROUP BY scenario_user_ratings.userid

both report result:

userid  AVG(scenario_user_ratings.rating)
1       3.3659
21      2.8000
22      3.2069

but this query yields different results

SELECT * FROM ( SELECT scenario_user_ratings.userid,
                       AVG(scenario_user_ratings.rating)
                FROM scenario_user_ratings
                GROUP BY scenario_user_ratings.userid) tabl 
WHERE tabl.userid < 5

Dev MySQL v5.0.7 result

userid  AVG(scenario_user_ratings.rating)
1       0.9999  <-- average values are always this, regardless

Web MySQL v5.1.56 result

userid  AVG(scenario_user_ratings.rating)
1       3.3659  <-- correct

Apart from the obvious comment of dev environment should always match production can someone please explain to me how putting the original query into another query is nuking my AVG() values to 0.99999 ? I’ve narrowed it down to that particular action, and only for this local version of MySQL.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:16:14+00:00Added an answer on May 27, 2026 at 7:16 am

    see here

    if you encounter the same problem, you can simply replace the AVG function by the combination SUM/COUNT.
    For example, the following query:

    SELECT student_name, AVG(test_score)
    FROM student
    GROUP BY student_name;
    can be replaced by the one below:
    
    SELECT student_name, SUM(test_score)/COUNT(test_score)
    FROM student
    GROUP BY student_name;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a webserver running quite standard Apache/php/MySQL and want to connect to this
i got an webserver running and old version of gambio (xt:commerce fork). The error_log
I have a staging Rails site up that's running on MySQL 5.0.32-Debian. On this
I have this query that's running too slow. I'm not sure what all info
This is a trickier problem than it sounds. I run Ruby/MySQL on many servers
I have a webserver running mysql and php which sends data to a json
On my Unix web server, I have two MySQL database servers running. One on
We've got a webserver running IIS. We'd like to run maybe a shared blog
I have a webserver running on my Windows XP computer. I have set the
I am in the process of migrating an existing webserver running IIS 6 to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.