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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:38:43+00:00 2026-06-04T03:38:43+00:00

I am working on a golf application that includes a scorecard system. I am

  • 0

I am working on a golf application that includes a scorecard system. I am storing each score for each player in the database and I need to come up with a query to determine tee order. So for example if the players have played 3 holes and the scores look like this…

Player    1  2  3
--------- -  -  -
Player 1: 3, 4, 3
Player 2: 2, 3, 3
Player 3: 2, 4, 3

… Then the order needs to look like this…

1.) Player 2
2.) Player 3
3.) Player 1

… So the players will be ordered by their scores compared to their opponents scores. Does that make sense? Is this even possible with a query, or should I write a function to parse a 2d array in code? I am using Java in that case.

My table structure looks like this:

  • Players (player id, and player name)
  • Rounds (round id, course id)
  • Scores (round id, player id, hole number, and score)
  • 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-04T03:38:44+00:00Added an answer on June 4, 2026 at 3:38 am

    I can see a solution that uses windows functions row_number() and an additional column in the database for the ordering at each level (or a recursive CTE in SQL Server). However, SQLite does not support this.

    Here is my recommendation on implementing the solution without doing a lot of querying backwards:

    (1) Assign the tee order for the first tee.

    (2) For each next tee, look at the previous score and the previous tee order:

    (3) Assign the new tee order by looping through the previous scores by ordering by highest score DESC and previous tee order ASC.

    Because you only have a few players per round, it is reasonable to do this in the app layer. However, if you had a database that supported window function, then you could more easily do a database only solution.

    I can’t resist. Here some code that will do this with a table to store the orders. You need to loop through, once per hole:

    create table ThisOrder (
        ThisOrderId int primary key autoincrement,
        RoundId int,
        Hole int,
        PlayerId int
    )
    

    Initialize it with each player in some order.

    Then, insert new rows into the table for each hole:

    insert into ThisOrder(RoundId, HoleId, PlayerId)
        select s.RoundId, s.Hole+1, s.PlayerId
        from Scores s join
             ThisOrder to
             on s.PlayerId = to.PlayerId and
                s.RoundId = to.RoundId and
                s.Hole = to.Hole
        order by s.Score DESC, to.Order ASC
    

    You’ll need to call this once for each hole, minus one.

    Then get your ordering as:

     select *
     from ThisOrder
     where roundid = <roundid> and hole = <thehole>
     order by ThisOrderId 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am working on an android database application and have fired query like this
Working on a website that has Employee and Branch entities, using a database table
I'm working on an application that runs on Windows Mobile 6 that needs to
Working with an API that can handle multiple connections (i.e. sessions), each of these
Working with a SqlCommand in C# I've created a query that contains a IN
Working in an application that stores entities in redis as a serialized binary blob.
Working on a legacy ASP.NET application we've found that ASP.NET session gets used for
Working on a bunch of forms at the moment and I'm finding that I
Working on a movie website and would love to find an API that I
Working on joining up two legacy DB systems into new database where I can

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.