Select cust.Cust_num,cust.name,
COUNT(distinct inv.Cust_num)AS "Total Orders"
Sum(inv.qty_Invoiced * inv.cost) as "Total Cost"
from custaddr cust
inner join
(
Select distinct cust_Num,isnull(qty_Invoiced,0)qty_Invoiced,isnull(cost,0)cost
from inv_hdr inv
left join inv_item InItem on InItem.inv_num = inv.inv_num
)inv on inv.cust_Name = cust.cust_Name
Where cust.cust_seq = '0' and inv.cust_Num ='FER001S'
Group by cust.Cust_num,cust.name