我有這樣的輸入:差價日期
+-----+---------+-------+------------+------------+
| key | company | price | week_start | price_diff |
+-----+---------+-------+------------+------------+
| 123 | xxx | 15 | 02-06-2015 | |
| 456 | xxx | 20 | 02-06-2015 | |
| 789 | yyy | 30 | 02-06-2015 | |
| 122 | zzz | 40 | 02-06-2015 | |
| 123 | xxx | 50 | 09-06-2015 | |
| 456 | xxx | 60 | 09-06-2015 | |
| 333 | yyy | 70 | 09-06-2015 | |
+-----+---------+-------+------------+------------+
預期輸出:
更新列price_diff
+-----+---------+-------+------------+------------+
| key | company | price | week_start | price_diff |
+-----+---------+-------+------------+------------+
| 123 | xxx | 15 | 02-06-2015 | |
| 456 | xxx | 20 | 02-06-2015 | |
| 789 | yyy | 30 | 02-06-2015 | |
| 122 | zzz | 40 | 02-06-2015 | |
| 123 | xxx | 50 | 09-06-2015 | 35 |
| 456 | xxx | 60 | 09-06-2015 | 40 |
| 333 | yyy | 70 | 09-06-2015 | |
+-----+---------+-------+------------+------------+
爲company= 'xxx'
和key = 123
我想利用價格差異根據week_start
。從以上輸入爲company = 'xxx'
和key = 123
,第二週有price = 50
,第一週價格= 15。我需要用這兩個值的差異更新price_diff。
在此先感謝
'y'呢?只有2個星期?他們總是喜歡02 --- 09 --- 16 ...或者可以有02 --- 04 --- 07 --- 10 --- 16 ...? –
感謝您的回覆..我有很多個星期,它將總是像02 --- 09 --- 16 ..我想更新price_diff周到周和它的唯一公司='xxx' – Rajesh