I have a problem with grouping in SQL Server Express 2005
I have a DATETIME COLUMN , but I want to group it only by date.
Here is my SQL expression:
SELECT (u.FirstName + ' ' + u.LastName) AS [FullName],d.user_id,CONVERT(varchar,d.log_date,101) AS log_date, min(d.login_time) as LOG_IN, max(d.logout_time) as LOG_OUT, sum(d.totaltime) as TOTHrs FROM tbldtr d INNER JOIN tblUsers u ON d.user_id = u.User_Id WHERE d.user_id = 'ADMIN1' and d.log_date BETWEEN '6/1/2013' AND '6/15/2013' GROUP BY DATEADD(day, DATEDIFF(day, 0, log_date), 0),u.FirstName,u.LastName,d.user_id order by d.log_date asc
but he gives me this error:
The column "tbldtr.log_date" is not valid in the selection list because it is not contained in the aggregate function or in the GROUP BY clause.
Thanks in advance.!
sql sql-server
Unknownymous
source share