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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:42:18+00:00 2026-06-03T00:42:18+00:00

i have a Datatable having following result from database ID Name Class FeeName Amount

  • 0

i have a Datatable having following result from database

ID  Name           Class    FeeName       Amount
9   gumman hgjgh    6Th      Fine            0
9   gumman hgjgh    6Th   Tution Fee       3000
9   gumman hgjgh    6Th   Lebority Fee     500
10  AAdil Hussain   5Th     Fine             0
10  AAdil Hussain   5Th   Tution Fee       3000
10  AAdil Hussain   5Th   Lebority Fee      500

i want to sum up amount against each ID so i implement following code

Dim TotalAmount As New DataColumn("TotalAmount", GetType(Double), "Sum(Amount)")
Dtable.Columns.Add(TotalAmount)

But result is following

ID  Name           Class    FeeName       Amount      TotalAmount
9   gumman hgjgh    6Th      Fine            0           7000
9   gumman hgjgh    6Th   Tution Fee       3000          7000
9   gumman hgjgh    6Th   Lebority Fee     500           7000
10  AAdil Hussain   5Th     Fine             0           7000
10  AAdil Hussain   5Th   Tution Fee       3000          7000
10  AAdil Hussain   5Th   Lebority Fee      500          7000

but i want to sum up amount against each Name or ID
i have not idea of LINQ

  • 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-03T00:42:19+00:00Added an answer on June 3, 2026 at 12:42 am

    I’m afraid a DataTable's Column-Expression cannot SUM(Amount)OVER(PARTITION BY ID).

    Here’s the LINQ solution:

    Dim idGroupAmounts =
        From row In DTable
        Group row By ID = row.Field(Of Int32)("ID") Into IDRowGroup = Group
        Select New With {
            .ID = ID,
            .IDRows = IDRowGroup,
            .IdSum = IDRowGroup.Sum(Function(row) row.Field(Of Double)("Amount"))
        }
    For Each idGrpAmount In idGroupAmounts
        Dim id = idGrpAmount.ID
        Dim totalAmount = idGrpAmount.IdSum
        Dim rows = idGrpAmount.IDRows
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataTable populated with values from a database. I have another datatable
I have small lightswitch application having CreateNewUser Screen. Screen fields comes from Datatable added
I'm having a bit of a problem. I have a datatable in the parent
I have datatable with column name tag and 100 rows of data.I need to
I have a DataTable with a Name column. I want to generate a collection
I have the following in my formula field: toText(((Sum ({DataTable1.Ending_Value}, {DataTable1.Name})) - (Sum ({DataTable1.Starting_Value},
I have a datatable having 44 rows. I have converted that to list and
I have a DataSet with a DataTable having the columns Number and Description. I
I'm importing data from an Excel sheet on to a DataTable using the following
I'm having a problem deleting rows from a datatable. In my program, I am

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.