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

  • Home
  • SEARCH
  • 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 6157685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:49:38+00:00 2026-05-23T20:49:38+00:00

I am developing a system using MySQL queries written by another programmer, and am

  • 0

I am developing a system using MySQL queries written by another programmer, and am adapting his code.

I have three questions:

1.

One of the queries has this select statement:

SELECT
   [...]
   AVG(mytable.foo, 1) AS 'myaverage'`, 

Is the 1 in AVG(mytable.foo, 1) AS 'myaverage' legitimate? I can find no documentation to support its usage?

2.

The result of this gives me average values to 2 decimal places, why?.

3.

I am using this to create a temp table. So:

(SELECT
    [...]
    AVG(`mytable`.`foo`, 1) AS `myaverage`,
FROM
    [...]
WHERE
    [...]
GROUP BY
    [...])
UNION
(SELECT
    [...]
FROM
    [...]
WHERE
    [...]
GROUP BY
    [...])
) AS `tmptable`
ORDER BY
    `tmptable`.`myaverage` DESC

When I sort the table on this column I get output which indicates that this average is being stored as a string, so the result is like:

9.3

11.1

In order to get around this what should I use?

Should I be using CAST or CONVERT, as DECIMAL (which I read is basically binary), BINARY itself, or UNSIGNED?

Or, is there a way to state that myaverage should be an integer when I name it in the AS statement?

Something like:

SELECT
    AVG(myaverage) AS `myaverage`, INT(10)

Thanks.

  • 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-23T20:49:38+00:00Added an answer on May 23, 2026 at 8:49 pm

    Just for anyone who’s interested, I must have deleted or changed my predecessors code so this AVG question was incorrect. The correct code was ROUND(AVG(myaverage),1). Apologies to those who scrathed their heads over my stupidity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was using a CASE called MAGIC for a system I'm developing, I've never
We are developing a considerably big application using Ruby on Rails framework (CRM system)
I'm developing a web system using regular PHP. This was my first experience with
I'm developing a class to manage the operations on a Mysql database. I have
I'm developing a system to allow users to vote on different subjects using a
I am currently in the mist of developing a website using PHP and MYSQL.
I am developing an MVC application using a mysql database. I searched a lot
I am currently developing a chat system using Node.js. My question is, how do
I'm developing a reward system for our VLE which uses three separate technologies -
I am developing a system as an aid to musicians performing transcription. The aim

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.