1
我的SQL查詢:子查詢還是不寫這個查詢?
select
*,
(select sum(Amount) as TotalAmount
from Payment
where Customer.Id = Payment.CustomerId)
from Customer
結果:
Id - CustomerName - CustomerPhoneNumber - TotalAmount
1 - TestUser - TestLastName - 3000
2 - TestUser2 - TestLastName2 - 2500
這是工作如我所料。但是有沒有更好的方法來獲得相同的結果?
什麼各種SQL的? – MatBailie 2012-01-12 16:39:04