Visa ett inlägg
Oläst 2010-01-28, 12:16 #2
yadis yadis är inte uppkopplad
Medlem
 
Reg.datum: Mar 2009
Inlägg: 66
yadis yadis är inte uppkopplad
Medlem
 
Reg.datum: Mar 2009
Inlägg: 66
Ovanstående nu löst
Så här blev det till slut om det intresserar nån:

SELECT Us.UserID, GroupRules.DistanceEachWeek,
IsNull(
( SELECT SUM(distance)
FROM Training
WHERE UserID = Us.UserID
AND GroupID = 11
AND Training.TrainingDate >= dbo.F_START_OF_WEEK(DateAdd(day,-7,GetDate()),2)
AND Training.TrainingDate <= dbo.F_END_OF_WEEK(DateAdd(day,-7,GetDate()),2)
) , 0) AS TotDistance
FROM [User] Us
JOIN [UserGroup] UsGrp ON Us.UserID = UsGrp.UserID
JOIN [Group] Grp on UsGrp.GroupID = Grp.GroupID
JOIN [GroupRules] on Grp.GroupID = [GroupRules].GroupID
WHERE Grp.GroupID = 11

Senast redigerad av yadis den 2010-01-28 klockan 12:24
yadis är inte uppkopplad   Svara med citatSvara med citat