Query with subquery returns only column names, no data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • docmom123
    New Member
    • May 2010
    • 2

    #1

    Query with subquery returns only column names, no data

    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
    Last edited by Dormilich; May 27 '10, 10:21 PM. Reason: Please use [code] tags when posting code
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    You are probably only getting column headings because there is no data in the table that matches the criteria of your query

    If you remove all of the where conditions do you get data back?
    Trying to narrow down where the query is loosing the data here.
    I can't see your data so I can't tell

    Comment

    • docmom123
      New Member
      • May 2010
      • 2

      #3
      Ah..you were so right! I worked backwards and found that I had a stinkin' typo in my condition! After that...slick! Thanks for the help! Rookie mistake!

      Comment

      Working...