Hi MS SQLSERVER,
I can see s.accountid in your query, but there is no table named s. Could you please help check the query?
From your description, do you need to sum up all the cost? If yes, you can use sum function and group by logic.
select distinct appc.provider,li.phonenumber,sum(li.totalcost) as TotalCost
from lineitem li
...
group by appc.provider,li.phonenumber