"Project nr" "Task" "Task deadline" "Task Type Production"
456 packed 1 april 2013 Packed
456 Leave production 3 april 2013 Leave Production
456 Flight date 9 april 2013 Flight Date
123 packed 1 april 2013 Packed
123 Leave production 6 april 2013 Leave Production
123 Flight date 9 april 2013 Flight Date
789 packed 1 april 2013 Packed
789 Leave production 9 april 2013 Leave Production
789 Flight date 9 april 2013 Flight Date
上記のようなリストが必要です 「生産終了」の日付でソートしたい プロジェクト番号は、上記のリストのように 3 つのグループにとどまる必要があります。
私はすでにこのSQLを持っています。リストは機能していますが、並べ替えは機能していません。エラー: マルチパート識別子 "タスク.[タスクの期限]" をバインドできませんでした。どうすればソートされますか?
SELECT [Project nr], Task, TaskDate
FROM (
SELECT MSP_EpmProject_UserView.[Project nr]
,MAX(CASE WHEN [Task Type Production] = 'Packed'
THEN [Task deadline]
END) AS Packed
,MAX(CASE WHEN [Task Type Production] = 'Leave Production'
THEN [Task deadline]
END) AS [Leave Production]
,MAX(CASE WHEN [Task Type Production] = 'Flight Date'
THEN [Task deadline]
END) AS [Flight Date]
FROM MSP_EpmProject_UserView
LEFT JOIN MSP_EpmTask_UserView
ON MSP_EpmProject_UserView.ProjectUID = MSP_EpmTask_UserView.ProjectUID
LEFT JOIN MSP_EpmAssignment_UserView
ON MSP_EpmTask_UserView.TaskUID = MSP_EpmAssignment_UserView.TaskUID
LEFT JOIN MSP_EpmResource_UserView
ON MSP_EpmAssignment_UserView.ResourceUID = MSP_EpmResource_UserView.ResourceUID
WHERE (MSP_EpmTask_UserView.TaskIsProjectSummary = 0)
GROUP BY MSP_EpmProject_UserView.[Project nr]
) data
UNPIVOT
(
TaskDate
for [Task] in ([Pack],[Leave Production],[Flight Date])
) piv
ORDER BY data.[Task deadline]
ORDER BY をコメントアウトした結果です。日付のないフィールドでも上記のような結果が欲しいです。
Project Nr Task TaskDate
0053 Packed 2013-02-05 17:00:00.000
0053 Leave Production 2011-04-26 17:00:00.000
0053 Flight Date 2011-04-22 17:00:00.000
0071 Leave Production 2011-06-24 17:00:00.000
0081 Leave Production 2012-03-09 17:00:00.000
0081-01 Leave Production 2012-03-09 17:00:00.000