This is my Query:
select top 60 * from ABC_Sessions (nolock)
where EntryDate > '06-22-2012 23:59:59'
GROUP BY TargetedID
then it gives me this error:
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.
The
*in your query expands to all the columns in your table.As the error message states, it’s not valid to select
SessionIDwithout an aggregate function (e.g.MAX).This would work: