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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:54:02+00:00 2026-06-12T04:54:02+00:00

My query is shown below select count(au.agentId), count(mr.agentId) from agents a left join assignunits

  • 0

My query is shown below

select count(au.agentId), count(mr.agentId)
       from agents a
       left join assignunits au on au.agentId=a.id
       left join assignmarketreport mr on mr.agentId=a.id                        
       where a.adminsId='0' 
       and a.id='29' group BY `mr`.`agentId`, au.agentId ASC

I am getting value of count(au.agentId) same as value of count(mr.agentId).

What I want:

For the below sample data

assignunits

agentId     status
     2      Y
     2      Y

assignmarketreport

agentId     status
     2      Y
     2      Y
     2      Y

agents

agentId     adminsId
     2      0

Now count(mr.agentId) should return 3
and count(au.agentId) should return 2

  • 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-12T04:54:04+00:00Added an answer on June 12, 2026 at 4:54 am

    try this:

     select au_agentId,mr_agentId 
      from 
              (select a.agentId,count(au.agentId) as au_agentId  
               from   agents a
               left join assignunits au 
               on     au.agentId=a.agentId
               where  a.adminsId='0'
               group  by a.agentId )au
          join
          (select a.agentId,count(mr.agentId) as mr_agentId   
           from   agents a
               left join assignmarketreport mr 
               on    mr.agentId=a.agentId
               where a.adminsId='0'
               group by a.agentId)mr  
          on    au.agentId=mr.agentId       
    

    SQl fiddle demo

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

Sidebar

Related Questions

I'm populating my select box using the query shown below: <%=f.select :acoustic, options_for_select(User.includes(:roles).where( :roles
When I run query number 1: SELECT id, name, COUNT(name) AS count FROM markers
I have a long list generated from a simple mysql select query. Currently (shown
I have the following query Select count(*) as TotalCount from ABC where ID in
The below shown is my query I need to order by with these three
I have a simple query to show a given users photos: SELECT pid FROM
I am performing a query which returns a list of comments as shown below:
below I have a query that will get the most common user agents for
I have this query (shown below) which currently uses temporary and filesort in order
I have a simple query in my code (shown below) written by my colleague.

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.