I have been working on this query for hours and all I can return are the column headers! What I need to return is an average for each marker, by date, for each subject. There are multiple dates for each marker and date. Thanks in advance for any help!!!
Code:
USE ALS_Smash_BBP
GO
SELECT BBP1.SubjectID
, BBP1.clinicdate
, AVG(BBP1.MaxSpd) AS MaxSpd_JR_RBHo
, AVG(BBP2.MaxSpd) AS MaxSpd_LL_JRo
, AVG(BBP3.MaxSpd) AS MaxSpd_LL_RBHo
, AVG(BBP4.MaxSpd) AS MaxSpd_RC_LCo
, AVG(BBP5.MaxSpd) AS MaxSpd_UL_RBHo
, AVG(BBP6.MaxSpd) AS MaxSpd_UL_LLo
, AVG(BBP7.MaxSpd) AS MaxSpd_UL_RC_LL_LCo
FROM
dbo.BBP_JerkCost_STATS051810 BBP1
JOIN dbo.BBP_JerkCost_STATS051810 BBP2 ON BBP1.SubjectID = BBP2.SubjectID
JOIN dbo.BBP_JerkCost_STATS051810 BBP3 ON BBP1.SubjectID = BBP3.SubjectID
JOIN dbo.BBP_JerkCost_STATS051810 BBP4 ON BBP1.SubjectID = BBP4.SubjectID
JOIN dbo.BBP_JerkCost_STATS051810 BBP5 ON BBP1.SubjectID = BBP5.SubjectID
JOIN dbo.BBP_JerkCost_STATS051810 BBP6 ON BBP1.SubjectID = BBP6.SubjectID
JOIN dbo.BBP_JerkCost_STATS051810 BBP7 ON BBP1.SubjectID = BBP7.SubjectID
WHERE
(BBP1.SubjectID = '0069' and BBP1.Marker = 'JR_RBHo')
or (BBP1.SubjectID = '0069' AND BBP2.marker = 'LL_JRo' )
OR (BBP1.SubjectID = '0069' AND BBP3.marker = 'LL_RBHo')
OR (BBP1.SubjectID = '0069' and BBP4.marker = 'RC_LCo')
OR (BBP1.SubjectID = '0069' AND BBP5.marker = 'UL_RBHo')
OR (BBP1.SubjectID = '0069' AND BBP6.marker = 'UL_LLo')
OR (BBP1.SubjectID = '0069' AND BBP7.marker = 'UL_RC_LL_LCo' )
GROUP BY BBP1.SubjectID
, BBP1.ClinicDate
Comment