I have two tables:
first one (amount):
amountid date amount
1 01.01.2011 100
2 02.01.2011 50
3 04.01.2011 200
4 10.01.2011 20
5 11.01.2011 5
second one (period):
periodid date
1 01.01.2011
2 03.01.2011
3 05.01.2011
I need group first table by times from second table, and sum (amount):
for this example answer is:
01.01.2011 150
03.01.2011 200
05.01.2011 25
help me with sql query please.
Sample data
The query