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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:04:25+00:00 2026-06-18T07:04:25+00:00

I have a Mysql query that selects some columns from 2 tables with an

  • 0

I have a Mysql query that selects some columns from 2 tables with an inner join. it is supposed to count the “Y” values from one table column and rturn this count with a Group By.

This is my query:

SELECT (SELECT Count(tblinterview.Contacted) FROM tblinterview WHERE tblinterview.Contacted = "Y") 
as Contact_Y , tbldata.RegionID, tbldata.BranchCode, tbldata.BranchDesc, tbldata.CampaignID,      tblinterview.EndTime      
FROM tbldata INNER JOIN tblinterview 
WHERE tblinterview.DataID = tbldata.DataId 
AND tblinterview.Complete = "Y"
GROUP BY tbldata.BranchCode, tbldata.RegionID, tblinterview.EndTime

By my result set is:
Where all the Contact_Y are the total count of all records instead of a grouping count.

Contact_Y      RegionID        BranchCode           BranchDesc     CampaignID   EndTime
1407            1           9725            Dada Motors        31           2012-01-26 12:51:12
1407            1           9725            Dada Motors        31           2012-01-31 10:25:18
1407            1           9725            Dada Motors        31           2012-02-01 11:30:37
1407            1           9725            Dada Motors        31           2012-02-01 14:48:57
1407            3           9732            Ballito Autohaus   37       2012-01-16 15:04:12
1407            3           9732            Ballito Autohaus   46           2012-01-18 11:59:53
1407            3           9732            Ballito Autohaus   31           2012-01-20 14:26:12
1407            3           9732            Ballito Autohaus   31           2012-01-20 16:05:48 

Could someone explain where my query is wrong?

  • 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-18T07:04:27+00:00Added an answer on June 18, 2026 at 7:04 am

    Give this a try

    SELECT   (SELECT Count(s.Contacted) 
            FROM tblinterview s
            WHERE s.Contacted = "Y" AND 
            tbldata .DataID = s.DataID) as Contact_Y , 
            tbldata.RegionID, 
            tbldata.BranchCode, 
            tbldata.BranchDesc, 
            tbldata.CampaignID,      
            tblinterview.EndTime      
    FROM    tbldata 
            INNER JOIN tblinterview  ON tblinterview.DataID = tbldata.DataId 
    WHERE   tblinterview.Complete = "Y"
    GROUP BY tbldata.BranchCode, tbldata.RegionID, tblinterview.EndTime
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL query that selects data from multiple tables and then orders
I have a MySQL query that: gets data from three tables linked by unique
I have a mysql query that uses union to join multiple queries into one
I have one query that INNER JOIN s Table A with Table B and
For example I have a mysql query that gets some data. Then runs another
I have a MySQL query like this: SELECT cp.plan_name, cp.plan_time FROM courses c INNER
I have a query that looks at partial matches within two mysql tables to
I have a reasonably straightforward MySQL query as follows: SELECT * FROM post INNER
I'm trying to use natural join to join two tables in mySQL that have
I have an application that executes the following MySQL query: SELECT 402 AS user_id,

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.