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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:50:18+00:00 2026-05-28T22:50:18+00:00

I appreciate this is a question that has been asked a few times, I

  • 0

I appreciate this is a question that has been asked a few times, I have looked at the answers I can find, and can’t seem to find a solution that fits my specific dataset… (mostly likely due to my newbies level, and not really fully understanding the syntax implications for ordering the various elements for the queries).

I’m trying to run two ‘counts’ into a single resulting table – I can get the individual tables just fine – be being able to aggregate the results would hugely speed up my analysis..

The specific queries are:

(1)

SELECT `PUID`,`DROID_V`,`SIG_V`,`SPEED`
     , COUNT(distinct NAME) as NoExt 
FROM sourcelist, main_small 
WHERE sourcelist.SourcePUID = 'MyVariableHere' 
  AND main_small.NAME = sourcelist.SourceFileName 
  AND sourcelist.hasExtension = 0 
GROUP BY `PUID`,`DROID_V`,`SIG_V`,`SPEED` 
ORDER BY `DROID_V` ASC, `SIG_V` ASC, `SPEED`;

and (2)

SELECT `PUID`,`DROID_V`,`SIG_V`,`SPEED`
     , COUNT(distinct NAME) as Ext 
FROM sourcelist, main_small 
WHERE sourcelist.SourcePUID = 'MyVariableHere' 
  AND main_small.NAME = sourcelist.SourceFileName 
  AND sourcelist.hasExtension = 1 
GROUP BY `PUID`,`DROID_V`,`SIG_V`,`SPEED` 
ORDER BY `DROID_V` ASC, `SIG_V` ASC, `SPEED`;

If what I want to do is possible, I’d really like to see if I can impliment a 3rd count:

(3)

SELECT `PUID`,`DROID_V`,`SIG_V`,`SPEED`
     , COUNT(distinct NAME) as All 
FROM sourcelist, main_small 
WHERE sourcelist.SourcePUID = 'MyVariableHere' 
  AND main_small.NAME = sourcelist.SourceFileName
GROUP BY `PUID`,`DROID_V`,`SIG_V`,`SPEED` 
ORDER BY `DROID_V` ASC, `SIG_V` ASC, `SPEED`;

I wonder if someone might be able to unpick what I have done, and let me know if what I want is possible – there is some common elements for the 3 counts, (the tables, the group conditions and the order details) and the difference being the WHERE conditions.

Even with the two count query, there would be null values, where count A would result in different sets than count B – so I wondered if the counts would need to result in the same basic shape (i.e. same row builds, just different count values, rather than count specific row builds resulting in a null return for one of the counts)

  • 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-28T22:50:18+00:00Added an answer on May 28, 2026 at 10:50 pm

    To combine (1) & (2) you can use a COUNT(distinct IF( .., .., ..)) construct and then remove the WHERE condition on hasExtension, allowing you to combine (3) in too:

    SELECT `PUID`,`DROID_V`,`SIG_V`,`SPEED`, 
        COUNT(distinct IF(sourcelist.hasExtension=1,NAME,NULL)) as Ext, 
        COUNT(distinct IF(sourcelist.hasExtension=0,NAME,NULL)) as NoExt,
        COUNT(distinct NAME) as `All`
    FROM sourcelist, main_small 
    WHERE sourcelist.SourcePUID = 'MyVariableHere' AND main_small.NAME = sourcelist.SourceFileName 
    GROUP BY `PUID`,`DROID_V`,`SIG_V`,`SPEED` ORDER BY `DROID_V` ASC, `SIG_V` ASC, `SPEED`;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been asked quite a few times, however, I have
I realize this question has been asked many times and I am have looked
I'm sorry if this question has been asked. I have looked but can not
I can see that this question has been asked several times, but none of
I am aware that this question has been asked before, but I have tried
Though this question has been asked several times but I really couldn't find any
I realise this question has been asked before however the previous answers have gotten
I know that this question has been asked before. I've tried implementing the answers,
This question has been asked a number of times, I have noted, but none
I've noticed that this question has been asked several times but none of the

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.