Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi All,

I have three tables linking with each other like below

TABLE A
PersonId, Code
123314 ABC
456788 ABC
878788 ABC
987878 CDE
025455 CDE

TABLE B
PersonId, Extn
123314 8888
456788 9878
878788 9999
987878 1010
025455 1111

TABLE C
Extn LocalCost STDCost ISDCost Date
8888 10 15 10 1-Jul
9878 20 30 12 1-Jul
1010 15 12 20 1-Jul
1010 10 10 10 2-Jul
1010 10 10 10 2-Jul

A.PersonId=B.PersonId
B.Extn=C.Extn
from these three tables i need result as below
Code LocalCost STDCost ISDCOst TOTAlCOst
ABC 30 45 22 97
CDE 25 27 30 82

I Need simple SQl Query to achive this

Thanks
Mohan
Posted
Updated 4-Aug-14 0:14am

1 solution

Hi,

Try this...


SQL
SELECT Code, LocalCost, STDCost, ISDCOst, LocalCost+STDCost+ISDCOst AS TOTAlCOst 
FROM TABLE_A A, TABLE_B B, TABLE_C C  
WHERE A.PersonId=B.PersonId
AND B.Extn=C.Extn



Hope you will get the required output.


Cheers
 
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