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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:25:41+00:00 2026-06-05T01:25:41+00:00

This query I’ve written, listing the top 25 in a sales competition, is showing

  • 0

This query I’ve written, listing the top 25 in a sales competition, is showing the wrong results.

Users aren’t showing that should be pretty far up on the list. Any idea what the issue could be?

SELECT u.fname, u.lname, SUM(p.point) as points 
  FROM comp_sale s, comp_product p, comp_user u
 WHERE s.prod_id = p.product_id 
   AND s.sale_id = u.wp_id 
 GROUP BY lname 
 ORDER BY points DESC limit 25

table comp_user:

user_id int(11) NO  PRI NULL    auto_increment
fname   varchar(255)    NO      NULL    
lname   varchar(255)    NO      NULL    
storename   varchar(255)    NO      NULL    
city    varchar(255)    NO      NULL    
phone   varchar(255)    NO      NULL    
wp_id   int(11) NO      NULL    
type    varchar(255)    NO      NULL    

table comp_sale

prod_id int(11) NO      NULL    
sale_id int(11) NO      NULL    
serial  varchar(255)    NO      NULL    

table comp_product

product_id  int(11) NO  PRI NULL    auto_increment
description varchar(255)    NO      NULL    
type    varchar(255)    NO      NULL    
cylinda_num int(11) NO      NULL    
eel_num int(11) NO      NULL    
point   int(11) NO      NULL    
  • 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-05T01:25:43+00:00Added an answer on June 5, 2026 at 1:25 am

    Try using a proper, ANSI standard GROUP BY

    SELECT
        u.fname, u.lname, SUM(p.point) as points
    FROM 
        comp_sale s
        JOIN
        comp_product p ON s.prod_id = p.product_id 
        JOIN
        comp_user u ON s.sale_id = u.wp_id
    GROUP BY
        u.fname, u.lname
    ORDER BY 
        points DESC 
    LIMIT 25
    

    Also, use explicit JOINs for clarity

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

Sidebar

Related Questions

This query seems to be valid, but I have 0 results. IEnumerable<XElement> users =
This query that I have is returning therapists whose 'therapistTable.activated' is equal to false
This query creates a mysql view that captures bad email address formats in one
This query: client.query({ text: SELECT * FROM users WHERE provider = ? AND remote_id
This query just doesnt seem to be very happy. Any ideas anyone? var results
This query does not work. I want all the results from a LEFT JOIN
This query is taking long time when endDate is null (i think that its
This query will return the top for all rows in MS Access. SELECT TOP
This query is very very slow and i'm not sure where I'm going wrong
This query will only return all records where Active=true and Exempt=false. It should be

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.