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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:46:59+00:00 2026-06-04T04:46:59+00:00

I have the following query SELECT c.cd, c.c_id FROM f f INNER JOIN s

  • 0

I have the following query

SELECT 
          c.cd,
          c.c_id 
FROM
          f f 
          INNER JOIN s s 
                    ON s.s_id = f.s_id 
          INNER JOIN c c 
                    ON c.c_id = s.c_id 
WHERE f.m_id = 2 
          AND f.deleted = 'no' 
GROUP BY s.c_id 
ORDER BY f.update_datetime DESC ;

Which returns a sample result set:

c.cd    c.c_id
moot    4
derp    5

I have another query based on the c.c_id of the above result set which iterates for each record in the above result set:

SELECT COUNT(*) as totals FROM s
WHERE c_id =?
AND status='good';

returns 7 when c_id=4 and returns 20 when c_id=5

Is there any way I can combine the two queries to form a result set like this?

c.cd    c.c_id  totals
moot    4       7
derp    5       20
  • 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-04T04:47:01+00:00Added an answer on June 4, 2026 at 4:47 am

    Try this:

    SELECT 
              c.cd,
              c.c_id,
              (SELECT COUNT(*) FROM  s WHERE c_id = c.c_id AND STATUS = 'good') totals 
    FROM
              f INNER JOIN s  ON s.s_id = f.s_id 
              INNER JOIN c c ON c.c_id = s.c_id 
    WHERE     f.m_id = 2 AND f.deleted = 'no' 
    GROUP BY  s.c_id 
    ORDER BY  f.update_datetime DESC ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query SELECT s.s_id, s.t_id, c.c_id, c.desc, sm.user_id FROM s s
I have the following query SELECT ID, TestReason FROM Test as t INNER JOIN
I have the following query: SELECT c.[ClientID] ,u.[AccessId] FROM [tblClient] c INNER JOIN [tblUser]
I have following SQL query: SELECT Count(*) AS CountOfRecs FROM tblAccount INNER JOIN tblAccountOwner
I have following SQL query SELECT TOP 10000 AVG(DailyNodeAvailability.Availability) AS AVERAGE_of_Availability FROM Nodes INNER
I have the following query: SELECT item.`ID`, item.`Name`, item.`UnitCost`, item.`Price`, discount.`rate` FROM item INNER
I have the following query SELECT e.topicShortName, d.catalogFileID, e.topicID FROM catalog_topics a LEFT JOIN
I have this query: select top(2) property_id_ref ,image_file ,property_name from property_master a inner join
The following query returns 2303 rows: SELECT a.* FROM cur_analises a INNER JOIN cur_materias_subsidiarias
I have the following query: SELECT TOP 25 CLIENT_ID_MD5, COUNT(CLIENT_ID_MD5) TOTAL FROM dbo.amazonlogs GROUP

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.