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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:44:04+00:00 2026-06-11T01:44:04+00:00

I have got a table which i have mentioned below, i need to get

  • 0

I have got a table which i have mentioned below, i need to get a total results avoiding duplicates , can any one provide any assistance or suggestions on how to get the results mentioned below, thankyu

ID      name    Total   Used
24     John     5        2
24     John     10       6
27     Peter    20       0
27     Peter    20       5

Result should be something like this

ID      name    Total   Used
24     John     15       8
27     Peter    40       5
  • 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-11T01:44:05+00:00Added an answer on June 11, 2026 at 1:44 am

    Looks like you just need to use SUM() on the two columns. Also use a GROUP BY on the id and name

    SELECT id, name, sum(total) All_total, sum(used) All_used
    FROM yourtable
    GROUP BY id, name
    

    see SQL Fiddle with Demo

    The GROUP BY field must include any other columns you are selecting which are not in an aggregate function, so for the example you would include both id and name in the GROUP BY.

    Edit #1 your query would be:

    SELECT [ID] , name, sum([Total]), sum([Used]), [GUID] 
    FROM [table].[dbo].[vw_data] 
    GROUP BY [ID], [name], [GUID] 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a table from which i need to get a piece of
In my database ( GoogleSEOData ), I have got one Table (GoogleMarkupList) and below
I have got a table which is coming with some data. One of the
I have got a table [newsletter] in the db, which saves the email address,
I've got a table recording views of programs. Each program can have two different
I have got a table which contains 5 column and query requirements: update row
I have got a table structure which is as follows: `CREATE TABLE "pages" (
I have got a Sales table which has fields like upgrade[yes/no] date upgraded[datetime] user[username]
I have got sql table which has 2 columns userid and products, userid is
I have got this table which has email address of 3 employees in SQL

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.