Click here to Skip to main content
15,892,575 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have Two Tables Despatch & Processing
Table Despatch
-------------
IID Dest From Dest To Weight(In Kg)
---------------------------------------------
1 Delhi Goa 50
2 Delhi Kolkata 60
3 Delhi Goa 70
4 Delhi Kolkata 80
5 Kolkata Delhi 90
6 Goa Kolkata 20
7 Goa Delhi 10
8 Goa Delhi 20
9 Goa Kolkata 15
10 Kolkata Delhi 5

2nd Table(Processing)
--------------------
pid iid Amount
----------------------------------------------
1 1 55
2 1 60
3 2 54
4 2 60
5 3 58
6 4 10
7 4 20
8 4 15
9 4 10
10 5 50
11 5 60
12 5 75
13 6 15
14 6 35
15 7 15
16 8 30
17 8 12
18 9 30
19 9 45
20 10 25


iid of despatch linked with processing and it is primary key in
despatch

Now What I want
Dest_From,Dest_To,sum(weight),sum(Amount) From These Two Tables and With Grouping In Dest_From,Dest_To
Through A Query Is It Possible?
Posted

You need to use JOIN and GROUP BY.

It should look something like this:

SELECT what_you_need_to_select FROM Despatch AS d
INNER JOIN Processing AS p ON d.iid = p.iid
GROUP BY your_group
 
Share this answer
 
Try Following Query


Select Dest_From,Dest_To,Sum(weight),Sum(Amount) from Despatch and Processing where Despatch.iid=Processing.iid Group By(Dest_From,Dest_To,Sum(weight) as Sweight ,Sum(Amount) as Samount)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900