请帮助解决以下问题:
在下表(示例)中,Dayscount 字段应该具有当前行中的 Txndate 和下一行中的 Txndate 之间的差异,前提是两行中的 Acctno 相同。如果 AcctNo 不同,则 Dayscount 应从给定的固定日期派生 - (示例中使用了 2012 年 3 月 31 日)。Product 列将包含 Amount1 和 DaysCount 的乘积
+--------+------------------+----------------------+---------+-------------+----------+
| P_ID | AcctNo | TxnDate | Amount1 | DAYSCOUNT | Product |
+--------+------------------+----------------------+---------+-------------+----------+
| 108161 | 0019061_A0100501 | 30/01/2012 | 250 | | |
| 108162 | 0019061_A0100501 | 03/02/2012 | -23000 | | |
| 108163 | 0019061_A0100502 | 09/02/2012 | -215 | | |
| 108164 | 0019061_A0100502 | 24/02/2012 | -1103 | | |
+--------+------------------+----------------------+---------+-------------+----------+
预期输出如下所示:
+--------+------------------+--------------------------+----------+-----------+---------------+
| P_ID | AcctNo | TxnDate | Amount1 | DAYSCOUNT | Product |
+--------+------------------+--------------------------+----------+-----------+---------------+
| 108161 | 0019061_A0100501 | 30/01/2012 | 250 | 4 | 1000 |
| 108162 | 0019061_A0100501 | 03/02/2012 | -23000 | 57 | -1311000 |
| 108163 | 0019061_A0100502 | 09/02/2012 | -215 | 15 | -3225 |
| 108164 | 0019061_A0100502 | 24/02/2012 | -1103 | 36 | -39708 |
| | | | | | |
+--------+------------------+--------------------------+----------+-----------+---------------+