0
我在SQL Server 2008中的兩個表:查詢來獲取不同行的數據到一個
會議:
MeetingID(bigint) MeetingStartTime(datetime) MeetingEndTime(datetime)
100 2014-01-05 17:10:13.000 2014-01-05 17:10:13.000
-----------------------------------------------------------------------
反饋:
MeetingID(bigint) QuestionID(int) Response(varchar 210)
100 1 Very Good
100 2 Average
-------------------------------------------------------------
我想要的結果是今日12.00AM-11.59PM:
MeetingID MeetingStartTime MeetingEndTime QuestionID Response QuestionID Response
100 2014-01-05 17:10 2014-01-05 17:10 1 Very Good 2 Average
我寫了一個查詢爲:
select m.MeetingID, m.MeetingStartTime, mMeetingEndTime, r.QuestionID, r.Response
from MEETING minner joinFEEDBACK ronm.MeetingID=r.MeetingID
where m.MeetingID<GETDATE() and m.MeetingID>DATEADD(hour,-12,GETDATE())
但結果我得到的是這樣的:
MeetingID MeetingStartTime MeetingEndTime QuestionID Response
100 2014-01-05 17:10 2014-01-05 17:10 1 Very Good
100 2014-01-05 17:10 2014-01-05 17:10 2 Average
請幫助。
問題ID可能是隨機的,不一定是1,2等等...... – user2681748