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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:21:30+00:00 2026-05-28T14:21:30+00:00

EDIT: OK, think I need to be clearer – I’d like the result to

  • 0

EDIT: OK, think I need to be clearer – I’d like the result to show all the ‘names’ that appear in the table acme, against the counts (if any) from the results table. Hope that makes sense?

Having a huge issue and my brain isn’t working as it should.

All I want to do is, in a single statement via a join, count the number of rows for a common field.

   SELECT name, COUNT(name) as Count FROM acme
   SELECT name, COUNT(name) as Total FROM results

I’m sure it should be something like this…

   SELECT acme.name, COUNT(acme.name) As Count, 
          COUNT(results.name) as Total 
   FROM acme 
   LEFT JOIN results ON acme.name = results.name 
   GROUP BY name 
   ORDERY BY name

But it doesn’t bring back the correct counts.

Thoughts, where am I going wrong…this, I know, will be very very obvious.

H.

  • 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-28T14:21:31+00:00Added an answer on May 28, 2026 at 2:21 pm

    From your feedback, this will get what you want. You need to FIRST get unique names / counts from the “ACME” file first… THEN join that to the results table for count of records from that, otherwise, you would end up with a Cartesian result of counts. If ACME had Name “X” 5 times and Results had “X” 20 times, your total would be 100. The query below will actually result with a single row showing “X”, 5, 20 which is what it appears you are looking for.. (for however many names exist in ACME).

    I’ve changed to a LEFT join in case there are names in the ACME table that DO NOT exist in the RESULTS table, it won’t drop them from your final answer

    select
          JustACME.Name,
          JustACME.NameCount,
          COALESCE( COUNT( * ), 0 ) as CountFromResultsTable
       from
          ( select a.Name
                   count(*) as NameCount
               from
                  acme a
               group by
                  a.Name ) JustACME
    
          LEFT JOIN results r
             on JustACME.Name = r.Name
       group by
          JustACME.Name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: This question was initially too general, I think. So What I really need
Edit I think there is some confusion, I am not using both of the
Edit: I think I've figured out how to do the binary data part. Double
EDIT: I have fixed all but two warnings now, so thank you all for
EDIT: I was an idiot. I simply had an image that was vertically long,
EDIT: See my answer below--> I am wanting to have a view that when
I'm making a task-based program that needs to have plugins. Tasks need to have
Say I have an interface that has as property another interface. Something like: interface
I am working on my website and I need to make some css that
You can specify one buffer for your file stream like that: char buf[BUFFER_SIZE]; std::ofstream

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.