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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:53:32+00:00 2026-06-16T10:53:32+00:00

I have below two query’s SUM the values Query1:* SELECT SUM(price) FROM TABLE1 WHERE

  • 0

I have below two query’s SUM the values
Query1:*

SELECT SUM(price) FROM TABLE1 WHERE acc_id = ‘555’

Query2:

SELECT SUM(price) FROM TABLE2 WHERE account = ‘555’ && active=’1′

I try to combine this two query but give wrong sum result , for example if query1 sum is: -86500 and Query2 sum is: 76000 , RESULT must be -10500 but result shown with a number like -486000

I’m trying like this, but i’m not getting expected result.

SELECT SUM(t1.price + t2.price) AS TotalCredit 
FROM TABLE1 AS t1, TABLE2 AS t2 
WHERE t1.`acc_id` = '555' && t2.`Account`='555' && t2.`Active`='1'

Table image : enter image description here

  • 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-16T10:53:33+00:00Added an answer on June 16, 2026 at 10:53 am

    Due to join the number of records get duplicated and you get a higher value for sum
    try this

    SELECT sum(prc) 
    FROM (
        SELECT SUM(price) prc FROM TABLE1 WHERE acc_id = '555'
        union all 
        SELECT SUM(price) prc FROM TABLE2 WHERE account = '555' && active='1'
    ) a
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the below query: --Total DLs-- select sum(DLs) as DLs_Total From ( Select
I have two query 1) tree and 2) units first query SELECT * FROM
I have this query below: Select count(CDT) as Actions From Player_Tapjoy Where Trunc(CDT) >=
I have a query which returns the below from joining two tables: +---------------+-----------------+ |
I have two tables described below. What I need is a single query that
I have code below: <select id=testSelect> <option value=1>One</option> <option value=2>Two</option> </select> <asp:Button ID=btnTest runat=server
I have the SQL query: SELECT ISNULL(t.column1, t.column2) as [result] FROM t I need
In the below i have a table1,table2 ,i am stuck with a query.I want
I am using java/oracle. i have below issue. SELECT DISTINCT id_one, status FROM sometable
Say I have the query below: WITH TEMP AS ( select 1 as id,

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.