0
我有一個協議表和一個計劃表。計劃是一個協議的孩子,並有一個FK的參考。SQL或SSIS找到丟失的日期範圍?
同一協議的所有計劃都應該填滿協議的整個範圍。但是,協議中還有一些缺失的計劃。
無論如何在SQL或SSIS中獲取「失蹤」計劃的列表?
協議表
+--------------+----------------------+--------------------+ | Agreement Id | Agreement Start Date | Agreement End Date | +--------------+----------------------+--------------------+ | 1 | 1/1/2010 | 12/31/2016 | +--------------+----------------------+--------------------+
計劃表
+--------------+---------+-----------------+---------------+ | Agreement Id | Plan Id | Plan Start Date | Plan End Date | +--------------+---------+-----------------+---------------+ | 1 | 1 | 1/1/2010 | 12/31/2010 | | 1 | 2 | 1/1/2012 | 12/31/2012 | | 1 | 3 | 1/1/2014 | 12/31/2016 | +--------------+---------+-----------------+---------------+
期望中的計劃表
+--------------+---------+-----------------+---------------+ | Agreement Id | Plan Id | Plan Start Date | Plan End Date | +--------------+---------+-----------------+---------------+ | 1 | 1 | 1/1/2010 | 12/31/2010 | | 1 | 4 | 1/1/2011 | 12/31/2011 | | 1 | 2 | 1/1/2012 | 12/31/2012 | | 1 | 5 | 1/1/2013 | 12/31/2013 | | 1 | 3 | 1/1/2014 | 12/31/2016 | +--------------+---------+-----------------+---------------+
所以基本上,我想要得到的協議1這將是這些失蹤的計劃行:
+--------------+---------+-----------------+---------------+ | Agreement Id | Plan Id | Plan Start Date | Plan End Date | +--------------+---------+-----------------+---------------+ | 1 | 4 | 1/1/2011 | 12/31/2011 | | 1 | 5 | 1/1/2013 | 12/31/2013 | +--------------+---------+-----------------+---------------+
mysql和ssis? –
任何涉及SQL或SSIS的解決方案都會非常棒! – Juc
Mysql是不同的產品 – Shadow