现在小弟想用sql语言求和:数据如下:
第一个数据是个panel data:
Firm | Date | Share |
11111 | 01/01/1986 | 200 |
11111 | 02/01/1986 | 200 |
11111 | 03/01/1986 | 0 |
11111 | 04/01/1986 | 200 |
11111 | 05/01/1986 | 200 |
11111 | 08/01/1986 | 200 |
11111 | 09/01/1986 | 200 |
11111 | 10/01/1986 | 0 |
11111 | 11/01/1986 | 200 |
11111 | 12/01/1986 | 200 |
11111 | 15/01/1986 | 200 |
11111 | 16/01/1986 | 200 |
11111 | 17/01/1986 | 200 |
11111 | 18/01/1986 | 0 |
11111 | 19/01/1986 | 200 |
11111 | 22/01/1986 | 200 |
11111 | 23/01/1986 | 200 |
11111 | 24/01/1986 | 200 |
11111 | 25/01/1986 | 200 |
11111 | 26/01/1986 | 0 |
11111 | 29/01/1986 | 200 |
11111 | 30/01/1986 | 200 |
11111 | 31/01/1986 | 200 |
11112 | 01/01/1986 | 200 |
11112 | 02/01/1986 | 200 |
11112 | 03/01/1986 | 0 |
11112 | 04/01/1986 | 200 |
11112 | 05/01/1986 | 200 |
11112 | 08/01/1986 | 200 |
11112 | 09/01/1986 | 200 |
11112 | 10/01/1986 | 0 |
11112 | 11/01/1986 | 200 |
11112 | 12/01/1986 | 200 |
11112 | 15/01/1986 | 200 |
11112 | 16/01/1986 | 200 |
11112 | 17/01/1986 | 200 |
11112 | 18/01/1986 | 0 |
11112 | 19/01/1986 | 200 |
11112 | 22/01/1986 | 200 |
11112 | 23/01/1986 | 200 |
11112 | 24/01/1986 | 200 |
11112 | 25/01/1986 | 200 |
11112 | 26/01/1986 | 0 |
11112 | 29/01/1986 | 200 |
11112 | 30/01/1986 | 200 |
11112 | 31/01/1986 | 200 |
第二个数据是一个事件集:
Firm | Event Start | Event End |
11111 | 03/01/1986 | 18/01/1986 |
11111 | 06/01/1986 | 25/01/1986 |
11112 | 09/01/1986 | 16/01/1986 |
现在想用sql语言求 (1)event_start前五天的share的和; (2). event_start开始以后五天的share的和; (3)event_end结束前五天的和; (4)event_end 结束后五天的和;(5)event_start 和 event_end 之间的和。
所有的求和都不包括event_start和event_end当天。
不胜感激!