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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:23:54+00:00 2026-05-25T11:23:54+00:00

If my Data is Name – playerID – matchID – Innings – Runs James

  • 0

If my Data is

Name - playerID - matchID - Innings - Runs
James   1   1   1   5
James   1   1   2   8
Darren  2   1   1   3
Darren  2   1   2   9
James   1   2   1   10
James   1   2   2   12
Darren  2   2   1   13
Darren  2   2   2   19

and my sql data is

$query = "SELECT playerID, name,
        SUM(runs) AS runs_scored,
        MAX(runs) AS highest_score
    FROM matchPlayer GROUP BY playerID";

Then the output would read

James has scored 35 runs with a highest score of 18
Darren has scored 44 runs with a highest score of 19

Now I wish to get the highest total scored in one match (that is combining innings 1 & 2)?
I have no idea how to start on this query 🙁

EDIT
The exact info I require is the HIGHEST match total, so James has 13 combined runs from matchID 1 and 22 combined runs from matchID 2 – so the answer I am after is 22.

  • 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-25T11:23:55+00:00Added an answer on May 25, 2026 at 11:23 am

    You need to do it in two stages:

    SELECT ms.playerID, mp.name, SUM(ms.runs_by_match) AS runs_scored,
        MAX(ms.runs_by_match) as highest_score
    FROM
        matchPlayer as mp
        INNER JOIN (
            SELECT playerID, matchID, SUM(runs) AS runs_by_match
            FROM matchPlayer
            GROUP BY playerID, matchID
        ) AS ms ON mp.playerID = ms.playerID
    GROUP BY
        ms.playerID, mp.name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i export table data with column name in text file in sql
I got the following data: [{'name': 'SqueezePlay', 'power': '1', 'playerid': '91:e2:b5:24:49:63', 'ip': '192.168.1.144:51346', 'canpoweroff':
I have a table emp with following structure and data: name dept salary -----
Is there a free source with basic yellow pages data(name,address, phone#)? I don't mind
I have table in data base name train delay, with columns train number(int), DelayTime(int),
I have the following sample data: Id Name Quantity 1 Red 1 2 Red
Here is a table structure (e.g. test): Field Name Data Type id BIGINT (20)
Given this data set: ID Name City Birthyear 1 Egon Spengler New York 1957
I've got the following tables: User Basic Data (unique) [userid] [name] [etc] User Collection
I need to build an application that accepts user input data (such as name,

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.