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 6252351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:47:06+00:00 2026-05-24T13:47:06+00:00

I have the following scenario: Game has GameUID, GameName Player has PlayerUID, PlayerName GamePlayer

  • 0

I have the following scenario:

  • Game has GameUID, GameName
  • Player has PlayerUID, PlayerName
  • GamePlayer has GamePlayerUID, GameUID, PlayerUID, FinishedPosition

I need to return back one row of a join between these three tables for each Game row where the return row contains the Player row with the lowest finished position.

Example,

Game

{some guid}, Game 1
{some guid}, Game 2
{some guid}, Game 3

Player

{some guid}, Player 1
{some guid}, Player 2

GamePlayer

{some guid}, {game 1 guid}, {player 1 guid}, 1
{some guid}, {game 1 guid}, {player 2 guid}, 2
{some guid}, {game 2 guid}, {player 1 guid}, 2
{some guid}, {game 2 guid}, {player 2 guid}, 1

My expected result would be

Result
-------
{game 1 guid}, Game 1, {player 1 guid}, Player 1
{game 2 guid}, Game 2, {player 2 guid}, Player 2

Now my instincts tell me that this should be the query:

select G.GameUID, G.GameName, V.PlayerUID, P.PlayerName
from Game G inner join (
    select top(1) GameUID, PlayerUID 
    from GamePlayer GP
    where GP.GameUID = G.GameUID
    order by FinishedPosition asc) as V on V.GameUID = G.GameUID
inner join Player P on V.PlayerUID = P.PlayerUID

Now, the problem with this query is that where GP.GameUID = G.GameUID results in a

multi-part identifier “G.GameUID” could not be bound

error.

If I exclude that and rely only on the join criteria, the subquery ALWAYS has the same first row and so it only joins one of the games.

I hope I’ve made this clear enough for someone to offer an answer.

BTW, this is being put in a View. I do not want to write a stored proc to do this unless absolutely necessary.

  • 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-05-24T13:47:07+00:00Added an answer on May 24, 2026 at 1:47 pm
    select G.GameUID, G.GameName, P.PlayerUID, P.PlayerName
    from Game G inner join (
        select GameUID, MIN(FinishedPosition) as FinishedPosition
        from GamePlayer GP
        group by GP.GameUID) as V on V.GameUID = G.GameUID
    inner join GamePlayer GP2 on (GP2.FinishedPosition = V.FinishedPosition and GP2.GameUID = V.GameUID)
    inner join Player P on (P.PlayerUID = GP2.PlayerUID)
    

    Whew. I think that does it? Let me know if it fails.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following scenarios: Scenario: Create a game with valid information Given I
I have the following scenario. The client code only has access to FooHandler, not
In a game application I have the following scenario: From the main game Activity
I have the following scenario: An app for Android devices that has a few
I have the following scenario: I'm creating a card game, and as part of
I have the following scenario. I'm working with a server which has a lib
I have the following scenario: My page has a dropdown list that allows user
I have following scenario, for which i need to write sql query. I have
I am trying to understand isolation/locks in SQL Server. I have following scenario in
I have the following scenario: in activity A, when a user clicks a button,

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.