
Hi, I need your help. I have to get a table with two columns. sum of the orders' total amount brouped by customers. Here is my sql query.
select sum(totalamount), account.name /* or contact.fullname if customer is a contact*/
from salesorder
left join account
on salesorder.customerid=account.accountid
left join contact
on salesorder.customerid=contact.contactid
group by customerid
*This post is locked for comments
I have the same question (0)I've corrected this query.
select sum(totalamount), account.name,contact.fullname
from salesorder
left join account
on salesorder.customerid=account.accountid
left join contact
on salesorder.customerid=contact.contactid
group by account.name, contact.fullname
Now I need to get the sum total amount and customer's name. I need to get customer's name in a one column instead of the account's name and contact's fullname.
Thanks in advance.