Multiple Child Records in single query

mfaisal.ce

Member
Local time
Today, 06:59
Joined
Dec 21, 2020
Messages
76
Dear Friends,

Kindly guide me,

1. T1 (ID,Name) --- Master Table
2. T2(ID,Qty) ----- Child Table

Now, my question is how i can make a query, which will sum(qty) from T2 against each record in T1....

Example ;

T1
IDName
1A1Pent
2A2Shirt
3A3Jeans


T2
IDQty
1A1100
2A250
3A370
4A150
5A245
6A3100
7A1100
8A280
9A390
 
You need to get the table structure correct

Can you upload a zipped copy of the database?
 
Dear Friends,

Kindly guide me,

1. T1 (ID,Name) --- Master Table
2. T2(ID,Qty) ----- Child Table

Now, my question is how i can make a query, which will sum(qty) from T2 against each record in T1....

Example ;

T1
IDName
1A1Pent
2A2Shirt
3A3Jeans


T2
IDQty
1A1100
2A250
3A370
4A150
5A245
6A3100
7A1100
8A280
9A390
Hi
See the attached example.
Study the relationships between table1 and table2

The query1 gives you the Total Quantities
 

Attachments

Select t1.ID, T1.[Name], Sum(T2.Qty) AS Total
From T1 Left Join T2 on T1.ID = T2.ID
Group by T1.ID, T1.[Name]

PS "Name" is the name of a property and so is a poor choice as a column name.
 

Users who are viewing this thread

Back
Top Bottom