Group by one table and sum from another table in Linq

yesman

I have this Linq query:

from i in data.Items
join tdi in data.TDItems on i.itemId equals tdi.itemId
group i by i.ItemId
into selection 
select new
{
    itemId = selection.Key
    number = selection.Sum(x => x.quantity) // quantity is a field in TDItems
}

How do I create this sum function? because I'm grouping by an attribute in the Items table, I can't call a Sum on the TDItems table.

Aducci
group new { i, tdi } by i.ItemId
...
select new 
{
   selection.Sum(x => x.tdi.quantity)
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Joining row from one table with the sum value from another table

From Dev

Mysql group by and having & sum of one column from table one

From Dev

How to SUM from another table in SQL in one view?

From Dev

How to sum a specific row from one table to another in SQL Server

From Dev

Mysql from sum one table column subtract sum of another table column

From Dev

Update sum from another table

From Dev

Updating table with select sum from another table

From Dev

Using LINQ to copy data from one table to another one on another server?

From Dev

MySQL - getting an associated list of values from one table in a query with a GROUP BY from another table

From Dev

PostgreSQL count entries from one table for a given id and mutliple that by rates in another table and sum it all up

From Dev

PostgreSQL count entries from one table for a given id and mutliple that by rates in another table and sum it all up

From Dev

Query to get the sum of a condition from one table, and add it to same condition in another table

From Dev

Select values from one table based on specific value of another table Linq

From Dev

Subtract rows of one table from another table

From Dev

inserting table values from one table to another

From Dev

Append data from one table to another table

From Dev

How to update one table from another table?

From Dev

update one table from another selected table

From Dev

Copy Data from one table to another table

From Dev

Value from one table on basis of another table

From Dev

Migrating from one table to another

From Dev

Subtract one table from another

From Dev

Calculating the sum of the quantities of one table based on dates in another table in sql

From Dev

Set two values in one table based on sum of a column in another table

From Dev

How to DELETE With SELECT SUM() FROM Table GROUP BY

From Dev

MySQL Count and SUM from second table with group by

From Dev

Linq query join one table row to another table multiple row

From Dev

Return Sum from another table in join with duplicates

From Dev

Trigger to update sum from another table MySQL

Related Related

  1. 1

    Joining row from one table with the sum value from another table

  2. 2

    Mysql group by and having & sum of one column from table one

  3. 3

    How to SUM from another table in SQL in one view?

  4. 4

    How to sum a specific row from one table to another in SQL Server

  5. 5

    Mysql from sum one table column subtract sum of another table column

  6. 6

    Update sum from another table

  7. 7

    Updating table with select sum from another table

  8. 8

    Using LINQ to copy data from one table to another one on another server?

  9. 9

    MySQL - getting an associated list of values from one table in a query with a GROUP BY from another table

  10. 10

    PostgreSQL count entries from one table for a given id and mutliple that by rates in another table and sum it all up

  11. 11

    PostgreSQL count entries from one table for a given id and mutliple that by rates in another table and sum it all up

  12. 12

    Query to get the sum of a condition from one table, and add it to same condition in another table

  13. 13

    Select values from one table based on specific value of another table Linq

  14. 14

    Subtract rows of one table from another table

  15. 15

    inserting table values from one table to another

  16. 16

    Append data from one table to another table

  17. 17

    How to update one table from another table?

  18. 18

    update one table from another selected table

  19. 19

    Copy Data from one table to another table

  20. 20

    Value from one table on basis of another table

  21. 21

    Migrating from one table to another

  22. 22

    Subtract one table from another

  23. 23

    Calculating the sum of the quantities of one table based on dates in another table in sql

  24. 24

    Set two values in one table based on sum of a column in another table

  25. 25

    How to DELETE With SELECT SUM() FROM Table GROUP BY

  26. 26

    MySQL Count and SUM from second table with group by

  27. 27

    Linq query join one table row to another table multiple row

  28. 28

    Return Sum from another table in join with duplicates

  29. 29

    Trigger to update sum from another table MySQL

HotTag

Archive