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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:02:43+00:00 2026-05-15T18:02:43+00:00

i have a table like this NAME VALUE —————– bla 1 bla 2 bla

  • 0

i have a table like this

NAME    VALUE
-----------------
bla      1
bla      2
bla      2
bla      3
bla      1
bla      4
bla      2

How can i do a sum of ONLY different values , and ignore the repeating values (is it possible?)?
Something like this :

 SELECT SUM(??condition?? value) as total FROM table

And the sum should be 10.

Thank you!

  • 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-15T18:02:44+00:00Added an answer on May 15, 2026 at 6:02 pm

    This should work:

    SELECT SUM(value) as total FROM (SELECT DISTINCT value FROM table) tmp;
    

    Source: http://forums.mysql.com/read.php?97,203188,203787#msg-203787

    SELECT SUM(DISTINCT value) as total FROM table
    

    Source: http://dev.mysql.com/doc/refman/5.1/en/group-by-functions.html#function_sum

    The second solution is better because it does not create temporary table. Therefore it is faster.

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

Sidebar

Related Questions

I have a MySQL table structured somewhat like this: type name value ===================== 1
I have a table that looks something like this: Name Year Value A 2000
Possible Duplicate: Concatenate row values T-SQL I have a table like this: ref_num name
I have a table that stores records like this: name | stat | value
I have a table that looks like this: id datatype name value 0 nvarchar(255)
I have a table which looks like this: id response_id name value 6 13
i have a table like this: +------------------------+ |Key| value | name | +---+-------+------------+ 1
I have a mysql table with entries like this: id name value date 1
I have a table like this: TABLE: FACTS ID KEY VALUE 1 name Jeremy
I have table like this- <table class='table'> <tr> <td class=td><input type=text name=name<%=f.getId()%> value=<%=f.getName()%>/> </td>

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.