Hi,I have below table, and query which return error. I was trying to add IN operator, but it seems that my knowledge is not good enough. ID IsLogin OnlineTimeJohn True 2013-10-30 12:00:00James True 2013-10-30 12:00:00select DATEDIFF(minute,(SELECT OnlineTime FROM IsLogin WHERE IsLogin = 'True'),GETDATE())
And, error:Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.With IN operator, which of course also not working:SELECT DATEDIFF(minute,(SELECT OnlineTime FROM IsLogin WHERE IsLogin IN ('True')),GetDate())
This is my entire query inside of stored procedure, which works fine if only 1 row is found.DECLARE @DiffDate varchar(max)SET @DiffDate = DATEDIFF(minute,(SELECT OnlineTime FROM IsLogin WHERE IsLogin = 'True'),GetDate())UPDATE IsLoginSET IsLogin = 'False', OnlineTime = convert(varchar(max), GetDate())WHERE IsLogin = 'True' AND @DiffDate > 1
Thanks in advance for help!