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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:57:59+00:00 2026-06-13T16:57:59+00:00

I have this query that works fine. It brings data from two tables, manager_details

  • 0

I have this query that works fine. It brings data from two tables, manager_details and users. What I need is to bring the sum of managers score BUT from week 1 to week 7. Week is another field in manager_details table which could have values from 0-x.

SELECT
  SUM(mng.score) AS accumulated_score,
  mng.manager_id AS manager_id,
  users.id,
  users.fname,
  users.lname
FROM manager_details AS mng
  JOIN users
    ON users.id = mng.manager_id
GROUP BY manager_id
ORDER BY accumulated_score DESC
LIMIT 5

In order to get score from week 1 to week 7, I have tried to add

SELECT
  SUM(mng.score) AS accumulated_score,
  mng.manager_id AS manager_id,
  users.id,
  users.fname,
  users.lname
FROM manager_details AS mng
WHERE  mng.week >= 1 AND mng.week <= 6    -- this line
  JOIN users
    ON users.id = mng.manager_id
GROUP BY manager_id
ORDER BY accumulated_score DESC
LIMIT 5

and got this

Error Code : 1064 You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near ‘join users
on users.id = mng.manager_id GROUP BY manager_id

and also tried

     ...         
     HAVING mng.week >= 1 AND mng.week <= 6  -- <-- 
     ...

I also put the HAVING clase after GROUP BY, before GROUP BY, at the end and did not work, got mysql error check syntax..etc.

I am doing something wrong, but not sure what is it.

So, What clause to use and where do I put that condition to filter my mng.score and get only scores that lie between weeks 1-7?

  • 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-13T16:58:01+00:00Added an answer on June 13, 2026 at 4:58 pm
    SELECT
      SUM(mng.score) AS accumulated_score,
      mng.manager_id AS manager_id,
      users.id,
      users.fname,
      users.lname
    FROM manager_details AS mng
      JOIN users
        ON users.id = mng.manager_id
    WHERE  mng.week >= 1 AND mng.week <= 6  
    GROUP BY manager_id
    ORDER BY accumulated_score DESC
    LIMIT 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this query that works fine SELECT t.username FROM users t LEFT JOIN
So I have this query that works perfectly: SELECT users.*, GROUP_CONCAT(categories.category_name) AS categories FROM
I have this SQL Query that pulls data from 3 tables. I am unable
I have an html5 query that works fine like this: tx.executeSql('SELECT * FROM bdreminders
I have this query that works fine. Its deletes records that are old based
I have this query that works fine. It selects rows into the SY.UserOptions table
I have this query that works just fine, however I want to change my
I have this linq query that works well (although it may be written better,
I have this working query that outputs URL and click counts from database. <?php
I have a criteria query that works just fine. Criteria criteria = getSession().createCriteria(getPersistentClass()); criteria.add(Restrictions.eq(employerId,employerId))

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.