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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:29:27+00:00 2026-05-25T00:29:27+00:00

I have a database that keeps track of game stats. Let’s say each game

  • 0

I have a database that keeps track of game stats. Let’s say each game consists of three rounds played to 10 points. So part of my table looks like this:

game | round1home | round1away | round2home | round2away | round3home | round3away 
-----------------------------------------------------------------------------------
  1  |     10     |      7     |     8      |     10     |    10      |     5
  2  |     10     |      4     |     10     |     6      |    6       |     10
  3  |     3      |      10    |     9      |     10     |    7       |     10 
  4  |     10     |      5     |     6      |     10     |    10      |     3
  5  |     8      |      10    |     10     |     7      |    7       |     10
  6  |     10     |      8     |     4      |     10     |    10      |     9

What I need to pull out is a list of games with the lowest 5 scoring away team rounds. In other words using the above table I would want the results to return these rows:

game 4: 3 points
game 2: 4 points
game 1: 5 points
game 4: 5 points
game 2: 6 points

My problem is the fact that I possibly could have the same game show up more than once in the list as game 2 does in the above example. I was able to write a query that worked except for adding in the duplicate games.

I assume I need to do a self join maybe then sort the rows? I’m having trouble wrapping my head around this one! Thanks so much for any help!

  • 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-25T00:29:28+00:00Added an answer on May 25, 2026 at 12:29 am

    You can do something like

    SELECT * FROM
    (
    SELECT game_id, round1away AS away_score
    ORDER BY round1away  
    LIMIT 5
    UNION 
    SELECT game_id,  round2away AS away_score
    ORDER BY round2away  
    LIMIT 5
    )a
    ORDER BY away_score
    LIMIT 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL database that keeps track of sports stats. I'm trying to
I have a database that keeps record history. For each update to a record,
I have a database that keeps track of books. The books table looks like
I have a simple database that keeps track of transactions from multiple players in
I am creating a database that will help keep track of which employees have
I have a database that tracks players through their attempts at a game. To
I have an iPhone (iOS) app that keeps data in a local SQLite database
My database has a table that keeps track of the department and user id.
Let's say you have a .NET system that needs to send out email notifications
i have DataBase function that calculate distance by coordinates CREATE OR REPLACE FUNCTION distance(lat1

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.