0

I need help

I have three tables as below :

customers [ CID , name , address , phone ] 

contracts [ ID , CID , TotalPrice , ] 

Payment [ ID , CID , pay ] 

I want to get the name of customer , his phone number and the value of sum( contracts .TotalPrice ) - sum(Payment.pay) as Remaning

but i have trouble to do this

I use microsoft access 2007

I use this statment

select customers.name , customers.phone , customers.address, (sum( contracts .TotalPrice ) - sum(Payment.pay)) as Remaning from customers  inner join  contracts on customers.CID=contracts.CID  inner join Payment on contracts.CID=Payment.CID ";

1 Answer 1

1
select customers.CID ,customers.[name] , customers.phone , customers.address, 
(sum( contracts .TotalPrice ) - sum(Payment.pay)) as Remaning 
from customers  inner join  contracts on customers.CID=contracts.CID  
inner join Payment on contracts.CID=Payment.CID GROUP BY customers.CID";

Edit: You need to enclose reserved keywords with '[]' in MS Access

Sign up to request clarification or add additional context in comments.

1 Comment

Note that name is a reserved word in Ms Access

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.