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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:28:01+00:00 2026-05-19T09:28:01+00:00

I need help with the following query, I will post an example of the

  • 0

I need help with the following query, I will post an example of the table.

     player | goals | gamedate

playername1 |  1    | 2011-01-01
playername2 |  2    | 2011-01-01
playername1 |  1    | 2011-01-02
playername3 |  1    | 2011-01-01
playername1 |  2    | 2011-01-03
playername1 |  1    | 2011-01-01
playername3 |  1    | 2011-01-01
playername2 |  2    | 2011-01-01
playername1 |  1    | 2011-01-04

There’s a lot more data like that I was wondering how can I write a query that will give the top players with most goals between a certain period of time (game season)?

Edit: It seems I was mistaken in the way the data was structured. I’m sorry for this. I will leave the previous table so that everyone can see the first answer to. I didn’t want to open a new question since it is essentially the same thing. My apologiies Haim.

`table1`
  id | gamedate

1    | 2011-01-01
2    | 2011-01-02
3    | 2011-01-03
4    | 2011-01-04
5    | 2011-01-05


`table2`
id | gameid  |      player | goals

 1 |   1     |  playername1 |  1  
 2 |   1     |  playername2 |  2  
 3 |   2     |  playername1 |  1 
 4 |   1     |  playername3 |  1
 5 |   3     |  playername1 |  2
 6 |   4     |  playername1 |  1
 7 |   2     |  playername3 |  1
 8 |   3     |  playername2 |  2
 9 |   5     |  playername1 |  1

Where gameid is a foreign key that’s referenced by ID in table1.

  • 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-19T09:28:02+00:00Added an answer on May 19, 2026 at 9:28 am

    replace the date you want to check ,
    and set the limit (in the example is 5) to how many players you want.

    SELECT player , sum(goals) AS top_scores FROM mytable 
    WHERE gamedate BETWEEN '2011-01-02' AND '2011-01-07'
    GROUP BY player ORDER BY top_scores DESC  LIMIT 5
    

    EDIT (according to edit of question , all you need is to add a join):

    SELECT player , sum(goals) AS top_scores FROM table2 t2
    LEFT JOIN table1 t1  ON t1.id = t2.gameid
    WHERE gamedate BETWEEN '2011-01-02' AND '2011-01-07'
    GROUP BY player ORDER BY top_scores DESC  LIMIT 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help with a query. Consider the following table: I need to select
I am new to django and need some quick help. How will the following
can someone please help me with the following query i need to update a
I need help writing a query that will validate a first expression and than,
I really need help getting this query right. I can't share actual table and
I need help writing a T-SQL query that will generate 52 rows of data
I need some help with query from multiple tables. My database: I have following
I need some help with a group by mysql query clause. Medals Table (this
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I need help doing the following: a preprocessor macro label(x) shall output #x, e.g.,

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.