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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:06:05+00:00 2026-06-15T16:06:05+00:00

Datatable1 Name Quantity A 2 B 5 C 3 D 4 Datatable2 Name Quantity

  • 0

Datatable1

Name   Quantity
A       2
B       5
C       3
D       4

Datatable2

  Name   Quantity
    A       1
    B       3
    F       4
    G       4

Expected Result After Joining Both Datatables Grouping By Name Then Sum Quantity for each group putting the result in a new datatable

 Name   Quantity
    A       3
    B       8
    C       3
    D       4
    F       4
    G       4

is it possible to this using LINQ? note that i access a field value as row.Field(of T)("Name")

  • 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-15T16:06:06+00:00Added an answer on June 15, 2026 at 4:06 pm

    Try this. I think you need Union if both the tables are the same

    Dim query = From x in ((From p in DataTable1
                    Select p).Union(From pd in DataTable2 Select pd))
                    Group x By Key = x.Name Into grouping = Group
                    let myProdSum = grouping.Sum(Function(x) => x.Quantity)
                    Select New With {.Name = grouping.Key, .TotalQty = myProdSum}
    
    ForEach s in query 
      Console.WriteLine("{0} : {1}" , s.Name, s.TotalQty)
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following in my formula field: toText(((Sum ({DataTable1.Ending_Value}, {DataTable1.Name})) - (Sum ({DataTable1.Starting_Value},
I have the following code that fills dataTable1 and dataTable2 with two simple SQL
For example, I need to fill lots of DataTables with SQLDataAdapter's Fill() method: DataAdapter1.Fill(DataTable1);
i've the following table +-------+--------+----------+ | catid | name | quantity | +-------+--------+----------+ |
I have a DataTable and want to group Name, LastName and Comment. The rest
I have created a Datagridview with 4 Columns, EJ: ID, Name, Quantity, other But
I have a master js file ( say name : my-dataTables.js ) and accessing
I have datatable with column name tag and 100 rows of data.I need to
I have a Datatable with Id(guid) and Name(string) columns. I traverse through the data
i have a datatable: +----------+--------+ | Rep Name | Volume | +----------+--------+ | Alex

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.