Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9060555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:15:35+00:00 2026-06-16T15:15:35+00:00

I am having trouble getting the format correct for a subquery. One of my

  • 0

I am having trouble getting the format correct for a subquery.

One of my queries displays the following:

This involves making calls to three tables (Ind Stats table, that pulls Game Stats, and Teams Name). As you can see, this query works fine.

What I’m having troubles with is how to pull each player that had a DD in that particular game. Players is another able within the database. All I can understand is that I should need a sub-query but sub-queries are not my strong suit.

Here is my code

  SELECT * FROM 

        (SELECT game_Date, 
        game_GameID,
        game_SeasonID,
        game_TeamCode,
        teams_Name,
        stats1_GameID,
        Sum(stats1_DD) AS 'TotGameDD'

        FROM game INNER JOIN teams INNER JOIN stats1
        ON 
        teams_TeamCode = game_TeamCode
        AND
        game_GameID = stats1_GameID

        GROUP BY game_GameID
        HAVING Sum(stats1_DD) >1
        ORDER BY Sum(stats1_DD) desc) t

    INNER JOIN  players INNER JOIN stats1 INNER JOIN game 
    ON stats1_GameID = game_GameID
            AND
    sstorm_rawstats1.stats1_PlayerID = sstorm_players.player_PlayerID

“

So, to be clear, this works fine:

  SELECT game_Date, 
    game_GameID,
    game_SeasonID,
    game_TeamCode,
    teams_Name,
    stats1_GameID,
    Sum(stats1_DD) AS 'TotGameDD'

    FROM game INNER JOIN teams INNER JOIN stats1
    ON 
    teams_TeamCode = game_TeamCode
    AND
    game_GameID = stats1_GameID

    GROUP BY game_GameID
    HAVING Sum(stats1_DD) >1
    ORDER BY Sum(stats1_DD) desc

I’m just trying to display the name of the players who recorded a DD in the row here. I’m getting the name now but it is counting all games that the player played. I’m close now.

enter image description here

UPDATE: I can now display the results in the table but it only shows one player who got a DD. I’m thinking I need a loop to display all the users who have a DD. Any help, much appreciated.

enter image description here

I just changed my above code by adding a GROUP BY stats1_DD and another AND in the FROM Statement as such:

  FROM game INNER JOIN teams INNER JOIN stats1
    ON 
    teams_TeamCode = game_TeamCode
    AND
    game_GameID = stats1_GameID
    AND
    game_PlayerID = player_PlayerID


    GROUP BY game_GameID, stats1_DD
    HAVING Sum(stats1_DD) >1
    ORDER BY Sum(stats1_DD) desc
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:15:36+00:00Added an answer on June 16, 2026 at 3:15 pm

    You should join the third table with the result set that coming from the query you already have or with the three table directly on the target column DD. Something like:

    SELECT * 
    FROM YourCrrentQuery t
    INNER JOIN ThePlayersTable p ON p.DD = t.DD;
    

    OR:

    SELECT * 
    FROM YourCrrentQuery t
    WHERE DD IN (SELECT DD 
                 FROM ThePlayersTable 
                 WHERE DD IS NOT NULL);
    

    Update: You will need to JOIN the subquery with the Players table like so:

    SELECT * 
    FROM 
    (
       SELECT 
         game_Date, 
         game_GameID,
         game_SeasonID,
         game_TeamCode,
         teams_Name,
         stats1_GameID,
         Sum(stats1_DD) AS 'TotGameDD'
         FROM game 
         INNER JOIN teams 
         INNER JOIN stats1  ON teams_TeamCode = game_TeamCode
                           AND game_GameID    = stats1_GameID
         GROUP BY game_GameID
         HAVING Sum(stats1_DD) >1
    ) t
    INNER JOIN players p ON t.TotGameDD = p.DD
    ORDER BY t.TotGameDD desc;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im having trouble getting a string (containing a URL) from one activity to another.
I'm having trouble getting the Jquery Validation to work with the following rules. I
I'm trying to learn THREE.js, and I'm having trouble getting a simple skybox to
I'm having trouble parsing a date format that I'm getting back from an API
I am new to Java and I'm having trouble getting the date format for
I'm having trouble getting a string URL to format correctly. The desired output is
I'm having trouble getting the right format here. I'm trying to get a proper
I'm having trouble getting this to work. I've searched this site and found many
I've seen this asked before and I am having trouble getting this to work
I'm working on a Wordpress site and am having trouble getting this page to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.