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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:44:16+00:00 2026-06-17T20:44:16+00:00

I have two tables. Let’s say the first one is numbers with user_id +

  • 0

I have two tables. Let’s say the first one is numbers with user_id + some number (double), can have multiple rows for each user_id. And then I have another users with user_id(PRIMARY) + product of all numbers for this user from the table numbers.

As records are inserted to or deleted from numbers, I need to recalculate users.product. Since there’s only one record being inserted at a time, I can do it with this query:

UPDATE users SET product=product*{number} WHERE user_id={some_id}

but as records are removed in bulk, it would require some ugly code to do this, it’s simpler to just recalculate the product. But, there’s no such function as PRODUCT. I can use

exp(sum(log(coalesce(*number*,1)))

But I’m not sure if I won’t end up with a wrong product of the numbers. The numbers will be in range from 1.00 to 9.99. How much of precision can be lost this way?

  • 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-17T20:44:17+00:00Added an answer on June 17, 2026 at 8:44 pm

    The answer to the your question is “yes”, if you are using floating point representations.

    In general, if you are multiplying numbers in a small range and only have a handful of numbers, this isn’t going to be a problem. If you are worried about it, then store the numbers in a fixed decimal representation.

    Your solution of taking logs is fine. For most applications this is going to produce quite sufficient accuracy. But, if you working on sending an orbitor to Mars, small errors can accumulate, and you shouldn’t depend on the database for high precision numerical accuracy.

    Note that the ordering of calculations can also affect numeric precision.

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

Sidebar

Related Questions

Let's say I have two tables one called Customers and one called CustomerAddresses. Then
Let's say I have two tables of similar structure, but one is empty and
Let's say I have two tables: Member ------------------------ | user_id | first_name | ------------------------
Let's say I have two tables with a one-to-many relationship. I want to create
let's say I have two tables: USERS: User_Id Hansen Nilsen Jensen Bob and ORDERS:
Let's say we have two tables, user and domain . User may have one
Let's say I have two tables employee and salary with a 1:N relationship (one
I have two tables with similar columns - let's say table A with column
Let's say i have two tables in db: Car and Part. Car owns arbitrialy
Let's say I have two tables, users and notes. Let's say the schemas look

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.