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

  • Home
  • SEARCH
  • 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 7612755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:59:37+00:00 2026-05-31T01:59:37+00:00

I know enough MySQL to do simple joins but I’m lacking the knowledge when

  • 0

I know enough MySQL to do simple joins but I’m lacking the knowledge when it comes to anything advanced. I know that I could strip out the rows in PHP but I believe that getting the query right is cleaner.

What I’m currently doing is:

Query:

SELECT DAYOFWEEK(r.`date`) AS weekNumber,  r.`date`AS scoreDate, qf.target, r.totalScore FROM results;

Result:

weekNumber, scoreDate, target, totalScore
4, '2012-02-29', 85, 100
3, '2012-03-06', 85, 100
3, '2012-03-06', 85, 75
3, '2012-03-06', 85, 42

Is it possible to:

  • group by weekNumber,
  • change the score date to show a ‘from and to date’ ,
  • sum up the target ‘s and divide by the number of rows grouped together
  • and the do the same for totalScore as we did with the target’s?

The outcome that I would like from the query is:

weekNumber, scoreDate, target, totalScore
4, '2012-02-29 to 2012-02-29', 85, 100
3, '2012-03-06 to 2012-03-06', 85, 72.3

Can someone help me create the query or tell me how I can produce the result that I’m looking for?

Thanks!

  • 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-31T01:59:39+00:00Added an answer on May 31, 2026 at 1:59 am
    SELECT q1, AVG(q2) as target, max(q3) as `end`, MIN(q3) as `start` from q GROUP BY q1
    

    the query above should do what you want. just change the q1 – q3 whit your fields. and q with you table name.

    outcome:

    ________________________________________
    | q1 | target | end        | start     |
    ----------------------------------------
    | 3  | 8.0000 | 2012-03-09 | 2012-03-08|
    ----------------------------------------
    | 4  | 2.0000 | 2012-03-07 | 2012-03-07|
    

    Database:

    ________________________
    | q1 | q2 | q 3        | 
    ------------------------
    | 3  | 7  | 2012-03-09 |
    | 3  | 9  | 2012-03-08 |
    | 4  | 2  | 2012-03-07 |
    

    source:
    http://www.w3schools.com/sql/sql_func_avg.asp

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

Sidebar

Related Questions

I have been learning PHP/Mysql for a while. But don't yet know enough to
I know enough to know that we need to get our application to deploy
I don't know if this is enough data to feed off of, but I
I've done enough Googling to know that if I have something like class SubObject
So, I don't know if the question is explicit enough, but here's my problem:
just for knowledge sake, i wanna know that how good is to use a
So I've inherited some django. The mySQL table is simple enough where parent is
I know that this is a popular topic, but I've yet to find an
I don't know enough about VB.Net (2008, Express Edition) yet, so I wanted to
Maybe I just don't know enough about structs and have been using them blindly

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.