Skip to content
Advertisement

SQL SUM Group by – based on ‘group’ from another table

I hope I am explaining this correctly.

I have 2 tables, with

first table (table1)

second table (table2)

Now, I need to sum the total (table1), based on Item Group (table2), Date and Block, in the end, final table:

How to achieve this with SQL query?

EDIT:

OK. It seems that this is an easy one. Shame on me. I didn’t know the join and Group By can be applied that way. SQL is really awesome. That saves tons of coding.

Advertisement

Answer

A join and a simple group by should work for you in this case:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement