假设房子经常被粉刷,我在一个简单的表中跟踪变化(“油漆”事件):
_______________________
/ PaintDate | NewColor \
|-----------|-----------|
| 1/2/2012 | Red |
| 3/5/2013 | Blue |
| 9/9/2013 | Green |
\___________|___________/
是否有一个 SELECT 语句可以给我一张房子在特定颜色的日期范围的表格?
期望的输出:
_______________________________
/ From | To | Color \
|----------|----------|---------|
| 1/2/2012 | 3/5/2013 | Red |
| 3/5/2013 | 9/9/2013 | Blue |
| 9/9/2013 | NULL | Green | -- Not repainted yet, the date in the 'To' column should be NULL
\__________|__________|_________/