0
我有以下「調查申請」結果的物理表。這不是說存儲結果的方式。有沒有想過這個TSQL挑戰?
正如你可以看到[84273x1x1]和[84273x1x2]是下拉列表問題,其中[84273x1x4]是一個自由文本,返回代碼。這
UserID; UserName; Email; [84273x1x1]; [84273x1x2]; [84273x1x4]; [84273x2x5]; [84273x2x6]; [84273x2x7];
1; "Name1"; "[email protected]"; "A101", "A203", "Test answer bla bla"; "A102", "A201", "Test answer bla bla"
2; "Name2"; "[email protected]"; "A102", "A202", "This is my comment"; "A101", "A203", "This is my comment";
的東西,我發現: [84273x1x1是對應於:
84273 = SurveyID
1 = PageID
1 = QuestionID
在回答表,它具有如下:
QID; Code; Answer;
1; A101; 1
1; A102; 2
1; A103; 3
2; A200; 0
2; A201; 1
2; A202; 2
2; A203; 3
5; A101; 1
5; A102; 2
5; A103; 3
6; A200; 0
6; A201; 1
6; A202; 2
6; A203; 3
On the question table:
QID; QuestionType; Title;
1; "DropDownList"; "How do you rate of GROUP-Q1";
2; "DropDownList"; "How do you rate of GROUP-Q1";
3; "Text"; "Comment of Q1";
4; "DropDownList"; "How do you rate of GROUP-Q2";
5; "DropDownList"; "How do you rate of GROUP-Q2";
6; "Text"; "Comment of GROUP-Q2";
結果,我會喜歡實現的是樞軸轉動:
UserID; Name; Email; Title; [Question1], [Question2]; [Question3]
1; "Name1"; "[email protected]"; "GROUP-Q1"; "1"; "3"; "Test answer bla bla";
1; "Name1"; "[email protected]"; "GROUP-Q2"; "2"; "1"; "Test answer bla bla";
2; "Name2"; "[email protected]"; "GROUP-Q1"; "2"; "2"; "Test answer bla bla";
2; "Name2"; "[email protected]"; "GROUP-Q2"; "1"; "3"; "Test answer bla bla";
因爲這個東西需要在TSQL-2005中完成。當我看到這個時,我的第一個想法就是它必須在Cursor中。
有沒有想過傢伙?
感謝
有多少個問題字段?這個數字是否有望增長? (我猜是的)。這種結構很難處理,最好的做法是將動態數據(問題列)轉換爲新表格,但我也理解這可能是不可能的。我不羨慕必須在這個結構上工作! – JonVD 2010-11-10 23:40:26