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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:37:01+00:00 2026-05-11T06:37:01+00:00

I have two tables, that is joined in some way. I’ve spent the last

  • 0

I have two tables, that is joined in some way. I’ve spent the last hour googling around, not finding any concrete answers that worked in my case.

The case is, table 1 is called Clients, and table 2 is called Projects. I need to list all the client names, followed by number of projects related to that project and the project title.

For example:

Client 1 (2 projects)
– Project 1 title
– Project 2 title

Client 2 (0 projects)

Client 3 (1 project)
– Project 1 title

How is this doable, in the simplest and easiest way?

  • 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. 2026-05-11T06:37:02+00:00Added an answer on May 11, 2026 at 6:37 am

    There are basically three parts to your query.

    1. Joining the tables
    2. Grouping the output by project
    3. Counting the projects per client

    The first is easy. It involves finding the client ID field in each table and use an JOIN clause specifying the two columns (one in each table) to correlate on. This will give you one row per project that also contains information for the matching client. This is almost what you’re asking for.

    It is tricky to put the second and third together in the one query and not one I would recommend. If you are going to be putting this in a program, then you can easily post-process the result from the query. To do this, you need to add an ORDER BY clause to specify sorting by client. That will put all the projects for each client in subsequent rows.

    Now you can write a loop to process the output. As it does to, it has to watch for two things:

    1. when the client ID changes
    2. counting the projects

    By doing this, it can easily display a ‘group header’ for each client, and a ‘group footer’ for the number of projects.

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

Sidebar

Related Questions

I have two tables that should be joined together by a foreign key relationship,
I have two tables that I have joined in a query like this IQueryable<Auction>
I have two tables that are joined. I've included the 'output' of the joined
i have two tables that are joined on a field rowid i need to
I have two tables, tblClient and tblBill which are joined on cltID. Some cltID
i have two joined tables. Now i need to print out some columns, but
I have two tables that need to be joined based on matching xml. The
I have two tables: gems and gemdetail that are left joined. I am trying
I have two tables that get joined regularly. Table One is about 1 Million
I have two tables, Pages and Posts that are in HABTM and are joined

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.