【发布时间】:2011-08-12 20:11:48
【问题描述】:
在我的项目中,我使用了一个名为“补偿”的表格,例如.....
+--------------------------------------------------------------+
| Id | receiver_Id | compensation | date |
|--------------------------------------------------------------|
| 1 | 5 | 50% | 2011-02-15 12:15:00 |
| 2 | 3 | 40% | 2011-04-05 18:35:00 |
| 3 | 3 | 30% | 2011-04-25 06:24:00 |
| 4 | 5 | 45% | 2011-04-21 19:05:00 |
| 5 | 5 | 60% | 2011-04-30 12:05:00 |
.......................
这里是date represents that the compensation is changed on that particular date。对于receiver 5,补偿为 50%before Feb 15 2011. And the compensation is45%fromthe date2011 年 2 月 15 日 12:15:01 至 2011 年 4 月 21 日 19:05:00`。等等……
在这里,当我为月份 APRIL 2011 为 receiver 5 创建 invoice 时,我必须使用 compensation as 45% 直到日期 21 April 2011 和 22 April 2011 to 30 April 2011 I have to use 60% 作为补偿...
但是如何获得一个月或两个日期之间的补偿,因为补偿可能在一个月内多次修改,如 id 4 和 5 所示......
请帮我writing SQL 完成上述操作,或者我必须在table structure 上创建changes 以使其简单......?
提前致谢
【问题讨论】:
标签: php mysql zend-framework select