Hi,
I am working on MSSQL 2000
I want query help
Table: Modlog
Columns and values are
userName dateAction action
david 2007-04-23 17:23:57.280 5
david 2007-04-23 17:24:50.873 3
david 2007-04-23 17:25:17.980 2
david 2007-04-24 15:15:10.230 2
lessoneditor1 2007-04-24 16:40:32.027 1
admin 2007-04-24 17:19:27.383 1
admin 2007-04-24 17:24:10.013 1
BetaUser1 2007-04-24 17:24:50.327 2
admin 2007-04-24 20:35:04.653 1
admin 2007-04-24 20:50:43.510 1
tony 2007-04-25 13:04:10.590 1
Admin 2007-04-25 14:37:24.053 1
admin 2007-04-25 17:20:56.263 1
tony 2007-05-01 16:59:54.167 5
tony 2007-05-01 17:00:04.777 5
I want
maximum action for each user with the date range passed by the user
Something like this
DECLARE
@fromDate nvarchar(20),
@toDate nvarchar(20)
SET @fromDate = '23/04/2007'
SET @toDate = '23/04/2007'
Select max(action), userName
from modlog
where
CONVERT(datetime, dateAction , 103) between @fromDate and @toDate
group by userName
It gives me error
Arithmetic overflow error converting expression to data type datetime.
Also I want all users with max actions
Many Thanks
Start Free Trial