這是我的查詢:發生了什麼,弄亂了我的GROUP BY查詢?
select top 60 * from ABC_Sessions (nolock)
where EntryDate > '06-22-2012 23:59:59'
GROUP BY TargetedID
然後它給了我這個錯誤:
Msg 8120, Level 16, State 1, Line 1 Column 'BI_Sessions.SessionID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
不能使用SELECT *與通過...分組。如果你選擇所有的行,你能解釋一下這個小組應該是什麼意思嗎?如果您有兩行具有相同的TargetedID,那麼您希望EntryDate和其他列的行是什麼?請顯示示例數據和所需結果,而不是您嘗試的無效查詢以及它應該返回的錯誤。 – 2012-07-23 14:48:24
你的問題是什麼?這個錯誤信息對我來說似乎很清楚。 – 2012-07-23 14:52:09