beeper
July 20th, 2005, 09:48 AM
I have database with tables like this:
http://img244.imageshack.us/img244/7411/a5if.jpg
I want to know how many cash is floating in contract
A report must look like that:
ID_PK | SUM(costs.Value) | SUM(foreincosts.Value) | SUM(service.Value)
I have example data like this:
Contract
http://img200.imageshack.us/img200/1673/19vp.jpg
Costs
http://img179.imageshack.us/img179/8407/23dm.jpg
ForeinCosts
http://img105.imageshack.us/img105/5049/23zd.jpg
Service
http://img169.imageshack.us/img169/3752/40mj.jpg
Query looks like this.
SELECT
contract.HowMutch,
SUM(costs.Value) AS CostSum,
SUM(foreincosts.Value) AS FCostSum,
SUM(service.Value) AS ServSum,
contract.ID_PK
FROM
contract
LEFT OUTER JOIN costs ON (contract.ID_PK=costs.IDcontract_FK)
LEFT OUTER JOIN foreincosts ON (contract.ID_PK=foreincosts.ID_Contract_FK)
LEFT OUTER JOIN service ON (contract.ID_PK=service.ID_Contract_FK)
GROUP BY
contract.ID_PK
But this is incorrect results. What is wrong with this query??
Please help.
http://img280.imageshack.us/img280/2450/55jm.jpg
http://img244.imageshack.us/img244/7411/a5if.jpg
I want to know how many cash is floating in contract
A report must look like that:
ID_PK | SUM(costs.Value) | SUM(foreincosts.Value) | SUM(service.Value)
I have example data like this:
Contract
http://img200.imageshack.us/img200/1673/19vp.jpg
Costs
http://img179.imageshack.us/img179/8407/23dm.jpg
ForeinCosts
http://img105.imageshack.us/img105/5049/23zd.jpg
Service
http://img169.imageshack.us/img169/3752/40mj.jpg
Query looks like this.
SELECT
contract.HowMutch,
SUM(costs.Value) AS CostSum,
SUM(foreincosts.Value) AS FCostSum,
SUM(service.Value) AS ServSum,
contract.ID_PK
FROM
contract
LEFT OUTER JOIN costs ON (contract.ID_PK=costs.IDcontract_FK)
LEFT OUTER JOIN foreincosts ON (contract.ID_PK=foreincosts.ID_Contract_FK)
LEFT OUTER JOIN service ON (contract.ID_PK=service.ID_Contract_FK)
GROUP BY
contract.ID_PK
But this is incorrect results. What is wrong with this query??
Please help.
http://img280.imageshack.us/img280/2450/55jm.jpg