請不要向我扔石頭,我知道已經有一些關於類似問題的問題(特別是this question),但與最後一個不同,我的問題有點不同。比方說,我有一個子查詢返回相似的結果如下:當一天中的某一天丟失時插入一行空值的SQL
+--------+--------------------------+-----------+----------+
| JOB_ID | START_TIME | STATUS | JOB_NAME |
+--------+--------------------------+-----------+----------+
| 1234 | 17-08-01 16:15:29,251000 | COMPLETED | EXTRACT |
+--------+--------------------------+-----------+----------+
| 1235 | 17-08-03 16:25:20,931000 | COMPLETED | EXTRACT |
+--------+--------------------------+-----------+----------+
| 1236 | 17-08-07 16:15:27,452000 | COMPLETED | EXTRACT |
+--------+--------------------------+-----------+----------+
| 1237 | 17-08-09 07:50:27,661000 | COMPLETED | EXTRACT |
+--------+--------------------------+-----------+----------+
| 1238 | 17-08-10 16:19:19,554000 | COMPLETED | EXTRACT |
+--------+--------------------------+-----------+----------+
我想什麼它做的是,當我缺少充滿除了START_TIME列誰也只是增加空值天要添加新行到一天。結果爲例,我想:
+--------+--------------------------+-----------+----------+
| JOB_ID | START_TIME | STATUS | JOB_NAME |
+--------+--------------------------+-----------+----------+
| 1234 | 17-08-01 16:15:29,251000 | COMPLETED | EXTRACT |
+--------+--------------------------+-----------+----------+
| | 17-08-02 00:00:00,000000 | | |
+--------+--------------------------+-----------+----------+
| 1235 | 17-08-03 16:25:20,931000 | COMPLETED | EXTRACT |
+--------+--------------------------+-----------+----------+
| | 17-08-04 00:00:00,000000 | | |
+--------+--------------------------+-----------+----------+
| | 17-08-05 00:00:00,000000 | | |
+--------+--------------------------+-----------+----------+
| | 17-08-06 00:00:00,000000 | | |
+--------+--------------------------+-----------+----------+
| 1236 | 17-08-07 16:15:27,452000 | COMPLETED | EXTRACT |
+--------+--------------------------+-----------+----------+
| | 17-08-08 00:00:00,000000 | | |
+--------+--------------------------+-----------+----------+
| 1237 | 17-08-09 07:50:27,661000 | COMPLETED | EXTRACT |
+--------+--------------------------+-----------+----------+
| 1238 | 17-08-10 16:19:19,554000 | COMPLETED | EXTRACT |
+--------+--------------------------+-----------+----------+
我知道我可能會問了很多在這裏,但如果你認爲你能幫助我將不勝感激!
你確定job_id是NULL,它會是主鍵嗎? –