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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:55:08+00:00 2026-05-17T19:55:08+00:00

I have a Master and Detail table, the Detail linking to the Master record

  • 0

I have a Master and Detail table, the Detail linking to the Master record on a FK reference.

I need to display all the data from the Master table, and the corresponding number of details for each record, i.e.

MASTER TABLE
ID Name  Age
1  John  15
2  Jane  14 
3  Joe   15

DETAIL
MasterID Subjects
1        Trigonometry
1        Chemistry
1        Physics
1        History
2        Trigonometry
2        Physics

Thus, when I ran the SQL statement, I would have the following result:

ID Name Age #Subjects
1  John 15  4  
2  Jane 14  2
3  Joe  15  0

Thanks!

  • 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-17T19:55:09+00:00Added an answer on May 17, 2026 at 7:55 pm

    This may be useful

    SELECT mt.ID, mt.NAME, mt.AGE, COUNT(d.MasterID) as [#Subjects]
    FROM MasterTable mt
    LEFT OUTER JOIN Detail d on mt.ID = d.ID
    GROUP BY mt.ID, mt.NAME, mt.AGE
    ORDER BY mt.ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a master table Person and a detail table Events I need to
I am wondering if it is okay to have master and detail table for
In my iPhone Core Data app I have it configured in a master-detail view
Quick background for those interested, I have a master detail table(options date), about 20
I have an app created from Xcode 4.5's boilerplate Master-Detail Application with CoreData, StoryBoards
Background: I have a Master-Detail view split view controller. In detail table view, I
I have a data model that consists of a master - detail relationship where
I have a master/detail app and I'm displaying a modal from my my master
I have a Master-Detail Relationship between two Tables , I Select a Record in
I have a master table (Team) and a detail table (TeamMember). TeamMember has a

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.