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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:33:11+00:00 2026-06-15T03:33:11+00:00

Hi all I am having my data table which is from my database is

  • 0

Hi all I am having my data table which is from my database is as follows

Name       Total
XYZ         20
XYZ         20
ABC         20

Now I would like to have my data table as follows

Name       Total
XYZ         40
ABC         20

I tried this linq from here Find duplicate and merge record into single datatable c# which works fine but as I am having my values from database I don’t know the type of the variable so can some one help me and give me the solution in non-linq 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-15T03:33:12+00:00Added an answer on June 15, 2026 at 3:33 am

    If you have two tables and you want to combine them all then the below is what you are after

    SELECT bothTables.Name, SUM(total) FROM
    (
       SELECT Name, SUM(total) as total FROM Table_1 GROUP BY Name
       UNION ALL
       SELECT Name, SUM(total) as total FROM Table_2 GROUP BY Name
    ) AS bothTables
    GROUP BY bothTables.Name
    ORDER BY bothTables.Name desc 
    

    or if you want to do it using your Data Table (dt in this example)

    var summedValues = from table in dt.AsEnumerable()
                       group table by table.Field<string>("Name")
                       into groupedTable
                       select new
                                 {
                                    Name = groupedTable.Key,
                                    Total = groupedTable.Sum(x => x.Field<int>("Total"))
                                 }; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an (access) database table which contains data I would like to populate
i'd like to write a function which grabs all fields from a database table
I’m having a problem getting the data from my database which I created to
I am designing a table in the database which will store log entries from
Essentially I've got a table holding user data, all of which is AES encrypted
Here is the table in which I am retrieving the data from an SQLite
I have one scenario where I need to select all files having aliencoders.numeric-digits like
Hi All I am currently having an issue calling a WCF service from a
Having been given the all clear to move code from my Page_Loaded method to
My jqGrid that does a great job of pulling data from my database, but

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.