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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:59:51+00:00 2026-05-26T09:59:51+00:00

I am using SUM() function. But SUM() sums the negative value in the column.

  • 0

I am using SUM() function. But SUM() sums the negative value in the column. In a column if the value is positive then it should be added and for negative values should be substracted and not added as the SUM()

20.00
20.00
20.00
20.00
-20.00
20.00
20.00
40.00
20.00
20.00
20.00
20.00
20.00
-20.00
-20.00
20.00

sum() should return 220 and not 440.
Is returning 440.

  • 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-26T09:59:52+00:00Added an answer on May 26, 2026 at 9:59 am

    To subtract negative numbers rather than add them you would use SUM(ABS(col)) but just to check this is what you actually need example results below.

    WITH YourTable(col) AS
    (
    SELECT 2 UNION ALL
    SELECT -5 
    )
    SELECT 
           SUM(ABS(col)) AS [SUM(ABS(col))],
           SUM(col) AS [SUM(col)]
    FROM YourTable
    

    Returns

    SUM(ABS(col)) SUM(col)
    ------------- -----------
    7             -3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code to sum values from multiple radio buttons : $(document).ready(function(){
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I have to query for total amount of a column using an aggregate function.
I'm using jQuery, and I want to sum up the values in my table
I'm using Node.js. After my sum function gets deleted, I would expect the typeof(sum)
I'm looking for help using sum() in my SQL query: SELECT links.id, count(DISTINCT stats.id)
I am calculating percentages in Analysis Services 2008 using MDX by dividing the sum
I'm getting an unexpected result for my query in group function. I'm using the
Python has a built in function sum , which is effectively equivalent to: def
I have a footerrow in my jqGrid where I sum up the values in

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.