Hi I’m pretty basic at SQL and having trouble trying to calculate a sub total of a field which is the following"sum(InItem.qty_Invoiced * InItem.cost) as "Total Cost"
Not sure if a loop of some kind is required? This is due to the fact that I have to connect to two tables Inv_Item and Inv_hdr via inv_num where an you can have more than one invoice number (seperated by invoice line no).Therefore i need something which would say For each invoice number listed from Inv_hdr in Inv_Item dosum(InItem.qty_Invoiced * InItem.cost) as "Total Cost"and obvously assign it to some variable to hold the total figure.Not sure how to do this which is why it properly not very clearer but if you can point me in the right direction taht would be great. My code so far is the followingselect inv.Cust_num,COUNT(inv.Cust_num)AS "Total Orders" --sum(InItem.qty_Invoiced * InItem.cost) as "Total Cost"from inv_hdr invinner join custaddr cust on inv.cust_num = cust.cust_num --left join inv_item InItem on InItem.inv_num = inv.inv_num where cust.cust_seq = '0' and inv.cust_Num ='FER001S'group by inv.Cust_num, cust.name
If this dosn't make sense let me know and ill try explain it clearermany thanksD.ARNOLD