調子:
Start date: 31-12-2012
End date: 01-04-2013
- モジュールは
project_id
module_start_date
読み込みは、との間の読み込みを表し、module_end_date
40user_id=6
%無料です。
SELECT [user_id], module_id, module_start_date, module_end_date,
1 - loading_percentage loading
FROM module_user_master_map
WHERE module_start_date >= '2012-12-31'
AND module_end_date <= '2013-04-01'
AND [user_id]=6
このクエリを使用すると、次の出力が得られます。
user_id | module_id | module_start_date | module_end_date | loading
-------------------------------------------------------------------
6 | 3 | 01-01-2013 | 31-01-2013 | 0.4
6 | 4 | 15-02-2013 | 28-02-2013 | 0.2
6 | 5 | 01-03-2013 | 15-03-2013 | 0.7
6 | 3 | 30-01-2013 | 30-01-2013 | 0.5
出力を注意深く見ると、ユーザーは日付で100%利用可能である、つまりユーザー01-02-2013
の14-02-2013
読み込みは1であることがわかります。
//上記の文の日付を修正しました。
次のような出力が欲しい
user_id | module_id | module_start_date | module_end_date | loading
-------------------------------------------------------------------
6 | 3 | 30-01-2013 | 30-01-2013 | 0.5
6 | 3 | 01-01-2013 | 31-01-2013 | 0.4
6 | Null | 01-02-2013 | 14-02-2013 | 1
6 | 4 | 15-02-2013 | 28-02-2013 | 0.2
6 | 5 | 01-03-2013 | 15-03-2013 | 0.7
6 | Null | 16-03-2013 | 01-04-2013 | 1
開始日と終了日からの日付を取得する機能があります。