i have this table
+------+--------+-------------------------+
| id | amount | start_date | end_date |
| 10 | 10 | 2012-01-15 | 2012-01-20 |
| 10 | 12 | 2012-01-14 | 2012-01-15 |
| 10 | 22 | 2012-01-15 | 2012-01-16 |
+------+--------+-------------------------+
i’d wish to find the sum between a given interval.
Example:
start date: 2012-01-13
end date: 2012-01-18
sum(amount) = 44.
start date: 2012-01-18
end date: 2012-01-21
sum(amount) = 10
is that possible with a single query?
is that possible at all?
EDIT
the logic behind is that if the intevarls (given one and inside the table) overlaps, i should get the row.
where
@StartDateand@EndDateare the dates you want to check between.