Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone

I got a problem like this

I have 4 table like this

Customer(CusID), Bill(BillID, CusID) and 
BillDetails(BillID, ProductID, Price, Amount), Product(ProductID)


I want to list of each customer and it money spent(Price*Amount) for all bills.
Could any one help me please? Any comment will be appriciate
Thanks very much
Posted
Updated 24-Nov-11 20:22pm
v2

SELECT 'MONEY SPENT' = Price * Amount FROM BillDetails


Just do the joining for other details.

Hope it helps!

Regards,
Eduard
 
Share this answer
 
Try as below Query.
SQL
Select C.CusID, Sum((BD.Price * BD.Amount)) as MoneySpent
From Customer C
Inner Join Bill B on C.CusID = B.CusID
Inner Join BillDetails BD on B.BillID = BD.BillID
Group By C.CusID;
 
Share this answer
 
Comments
nguyenle.it 25-Nov-11 3:51am    
Thanks so much!!
It work like a charm
RaisKazi 25-Nov-11 5:43am    
Cheers!

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