TimothyCederdahl
Programmer
I get this error when using "> dateadd(day,7,(select TRDate from SC_Trophies Where UserId = 29))" the full query is below with the error. Any ideas on how I could resolve this problem would be most welcomed. The query works fine it seems with out the date part.
Thanks in Advance,
Tim
Msg 512, Level 16, State 1, Line 23
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
insert into SC_Trophies (
UserId,
SportId,
TypeID,
Value,
TDID,
TrDate
)
Select
us.userid as UserID,
1 as SportId,
2 as TypeId,
0 as Value,
9 as TDID,
getdate() as TrDate
FROM SC_UserStats us
WHERE not exists (select * from SC_TROPHIES where UserID = us.UserID and SportId=1) and SportId=1 and
UserID in (SELECT Top 10 (UserID) FROM SC_UserStats Order By LWOUP)
begin
Update SC_Trophies
Set Value = Value + 1
where SC_TROPHIES.USERID in (SELECT Top 10 (UserID) FROM SC_UserStats where SportId=1 Order By LWOUP) and SportId=1 and TDID=9 and getdate() > dateadd(day,7,(select TRDate from SC_Trophies Where UserId = 29))
end
Thanks in Advance,
Tim
Msg 512, Level 16, State 1, Line 23
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
insert into SC_Trophies (
UserId,
SportId,
TypeID,
Value,
TDID,
TrDate
)
Select
us.userid as UserID,
1 as SportId,
2 as TypeId,
0 as Value,
9 as TDID,
getdate() as TrDate
FROM SC_UserStats us
WHERE not exists (select * from SC_TROPHIES where UserID = us.UserID and SportId=1) and SportId=1 and
UserID in (SELECT Top 10 (UserID) FROM SC_UserStats Order By LWOUP)
begin
Update SC_Trophies
Set Value = Value + 1
where SC_TROPHIES.USERID in (SELECT Top 10 (UserID) FROM SC_UserStats where SportId=1 Order By LWOUP) and SportId=1 and TDID=9 and getdate() > dateadd(day,7,(select TRDate from SC_Trophies Where UserId = 29))
end