Landmine
Landmine

Reputation: 1789

Use LINQ to Total Columns

I'm trying to get LINQ SQL to grab and total this data, I'm having a heck of a time trying to do it too.

enter image description here

Here is my code, that doesn't error out, but it doesnt total the data.

        ' Get Store Record Data
        Dim MyStoreNumbers = (From tnumbers In db.Table_Numbers
        Where tnumbers.Date > FirstOfTheMonth
        Select tnumbers)

I'm trying to create a loop that will group the data by DATE and give me the totals so I can graph it.

As you can see, I'd like to set totals for Internet, TV, Phone, ect... Any help would be great, thank you!

Upvotes: 0

Views: 408

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726489

You can group and total the numbers one by one, like this:

From tnumbers In db.Table_Numbers
Where tnumbers.Date > FirstOfTheMonth
Group by tnumbers.Date
Into TotalPhone = sum(tnumbers.Phone)
Select Date, TotalPhone

Here is a link with explanations of this subject from Microsoft.

Edit: added grouping

Upvotes: 1

Related Questions