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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:24:16+00:00 2026-05-10T22:24:16+00:00

The following query returns strange results for me: SELECT `Statistics`.`StatisticID`, COUNT(`Votes`.`StatisticID`) AS `Score`, COUNT(`Views`.`StatisticID`)

  • 0

The following query returns strange results for me:

SELECT     `Statistics`.`StatisticID`,     COUNT(`Votes`.`StatisticID`) AS `Score`,     COUNT(`Views`.`StatisticID`) AS `Views`,     COUNT(`Comments`.`StatisticID`) AS `Comments` FROM `Statistics` LEFT JOIN `Votes` ON `Votes`.`StatisticID` = `Statistics`.`StatisticID` LEFT JOIN `Views` ON `Views`.`StatisticID` = `Statistics`.`StatisticID` LEFT JOIN `Comments` ON `Comments`.`StatisticID` = `Statistics`.`StatisticID` GROUP BY `Statistics`.`StatisticID` LIMIT 0, 10 

I’m querying this on a table structure like the following:

(only data relevant to Statistics.StatisticID = 8)

Votes

StatisticID     8 

Views

StatisticID     8     8 

Comments

StatisticID     8     8     8     8     8 

Now if I run this query I get the following result set:

StatisticID    Score    Views   Comments      8           5        5        5 

I knwo where the 5 comes from – the number of Comments – and this works if I take the comments statement out. Can anyone debug this as this is out of my reach (I’m relatively new with SQL).

Thanks, Ross

  • 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. 2026-05-10T22:24:17+00:00Added an answer on May 10, 2026 at 10:24 pm

    Assuming you have an id field or similar on the votes/views/comments:

    SELECT     `Statistics`.`StatisticID`,     COUNT(DISTINCT `Votes`.`VoteID`) AS `Score`,     COUNT(DISTINCT `Views`.`ViewID`) AS `Views`,     COUNT(DISTINCT `Comments`.`CommentID`) AS `Comments` FROM `Statistics` LEFT JOIN `Votes` ON `Votes`.`StatisticID` = `Statistics`.`StatisticID` LEFT JOIN `Views` ON `Views`.`StatisticID` = `Statistics`.`StatisticID` LEFT JOIN `Comments` ON `Comments`.`StatisticID` = `Statistics`.`StatisticID` GROUP BY `Statistics`.`StatisticID` LIMIT 0, 10 

    Not tested it, but think it should work. (We have to use the different field because the statisticID will always be the same within a given group …)

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

Sidebar

Related Questions

The following query returns data right away: SELECT time, value from data order by
I have the following query running against a mysql database: select value from fact_data
The following query returns >7000 rows when each table only has 340 rows. SELECT
I am usung oracle 11g. Suppose the following query returns n rows. SELECT t.id,t.from_date,t.price
The following query returns the total amount of orders, per week, for the past
The following query returns values for months with sales but not for months where
I have the following query which returns a list of questions and the possible
I would like to create a query that returns rows in the following format:
I'm calling the following URL using YQL http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22UTG.L%22)%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=cbfunc this returns the following in JSON
I am trying to come up with a query that will return comments following

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.