我有一個像這樣的表,我通過適度返工this數據+ SQL來顯示白天,但我想添加空天以及與在右手邊運行理貨。爆炸一個SQL表,並插入一行,每天不存在
╔════════════╦════════╦═════════╦════════╗
║ day ║ num1 ║ num2 ║ tally ║
╠════════════╬════════╬═════════╬════════╣
║ 2016-06-10 ║ 9.99 ║ ║ 9.99 ║
║ 2016-06-12 ║ 136.00 ║ 9.99 ║ 145.99 ║
║ 2016-06-14 ║ ║ 145.99 ║ 145.99 ║
║ 2016-06-18 ║ 9.99 ║ 145.99 ║ 155.98 ║
║ 2016-06-19 ║ 210.00 ║ 145.99 ║ 365.98 ║
║ 2016-06-22 ║ 50.00 ║ 9.99 ║ 279.98 ║
║ 2016-06-28 ║ 69.99 ║ 59.99 ║ 349.97 ║
╚════════════╩════════╩═════════╩════════╝
我不知道如何讓這個錶轉換爲:
╔════════════╦════════╦═════════╦════════╗
║ day ║ num1 ║ num2 ║ tally ║
╠════════════╬════════╬═════════╬════════╣
║ 2016-06-10 ║ 9.99 ║ ║ 9.99 ║
║ 2016-06-11 ║ ║ ║ 9.99 ║ <- new row with previous value
║ 2016-06-12 ║ 136.00 ║ 9.99 ║ 145.99 ║
║ 2016-06-13 ║ ║ ║ 145.99 ║ <- new row with previous value
║ 2016-06-14 ║ ║ 145.99 ║ 145.99 ║
║ 2016-06-15 ║ ║ ║ 145.99 ║ <- new row with previous value
║ 2016-06-16 ║ ║ ║ 145.99 ║ <- new row with previous value
║ 2016-06-17 ║ ║ ║ 145.99 ║ <- new row with previous value
║ 2016-06-18 ║ 9.99 ║ 145.99 ║ 155.98 ║
║ 2016-06-19 ║ 210.00 ║ 145.99 ║ 365.98 ║
║ 2016-06-20 ║ ║ ║ 365.98 ║ <- new row with previous value
║ 2016-06-21 ║ ║ ║ 365.98 ║ <- new row with previous value
║ 2016-06-22 ║ 50.00 ║ 9.99 ║ 279.98 ║
║ 2016-06-23 ║ ║ ║ 279.98 ║ <- new row with previous value
║ 2016-06-24 ║ ║ ║ 279.98 ║ <- new row with previous value
║ 2016-06-25 ║ ║ ║ 279.98 ║ <- new row with previous value
║ 2016-06-26 ║ ║ ║ 279.98 ║ <- new row with previous value
║ 2016-06-27 ║ ║ ║ 279.98 ║ <- new row with previous value
║ 2016-06-28 ║ 69.99 ║ 59.99 ║ 349.97 ║
╚════════════╩════════╩═════════╩════════╝
數據庫是否有這對於每一日的記錄日曆類型的表? –
@DanBracuk是的,這是第一個表,但它只創建一個記錄存在時的行。我需要一堆空白的日期行,即使所有其他值對於該行都是空白的,也會帶來理貨值。 – eveo