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 9249803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:17:24+00:00 2026-06-18T10:17:24+00:00

Basically, two queries that do a similar averaging, are giving me different results; the

  • 0

Basically, two queries that do a similar averaging, are giving me different results; the “actual” value expected is 81.25, so with normal rounding, you would think that CAST-ing it to DECIMAL(10,1) would result in 81.3, but one of the queries (the first one) gives 81.2

Here’s the examples:

CAST( AVG( t1.NumCorrect / 7.0 * 100.0 ) AS decimal(10,1))

vs.

CAST( AVG( t2.PercentCorrect ) AS decimal(10,1))

The only difference, as far as I can tell, is that PercentCorrect is type REAL, and NumCorrect is type FLOAT.. but those are both floating-point types, so why would casting them behave differently?

In the first line, NumCorrect is like a “# correct out of 7 possible”, so I’m calculating a “Percent” on-the-fly, which is then AVG’d; whereas in the 2nd example, the Percent is pre-calculated, and I just need it AVG’d. Again, first line is the one that gives 81.2 instead of 81.3

If I need to provide more context with the surrounding queries or source-data, I can try… just let me know.

  • 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-06-18T10:17:25+00:00Added an answer on June 18, 2026 at 10:17 am

    Execute this on SQL and you’ll get your answer.

    select 1425554.3/5457.251
    
    
    select convert(real, (1425554.3/5457.251))
    

    Basically, t2.PercentCorrect is already casted/converted to real which truncates the decimal point values. t1.NumCorrect is divided on the fly and all decimal points are processed on the avg function.

    Hope this helps!

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

Sidebar

Related Questions

I have two queries that are basically the same: OLD TRANSACTIONS QUERY SELECT t.payment_method,
I am doing some pre-processing on my database. Basically two queries, one is INSERT
I am using WickedPDF, and I have basically two gems that include the binaries:
I have some localization problems in my webpage. There are basically two problems (that
I'm new to these types of MySQL Queries. Basically, I have two tables in
Basically I have a table that versions products, so it has two columns of
I have two SQL queries that I'm running from a C# winform, and I
I have two MySQL queries in my PHP code. Basically I need the two
Have a small problem with LINQ queries. Basically I have two lists, filled with
I'm trying to parse results from queries over HTTP that can return up 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.