Tuesday, 15 September 2015

sql - multiple calculations across tables -



sql - multiple calculations across tables -

i trying total cost of invoices customer. ideally end format 2 columns [customer name] , [total of invoices]. have broken downwards parts far can check , improve understand process of joining tables , have done calculation total of items on each invoice stuck.

as can see screenshot ( had link google docs couldn't post image here - sorry) getting company name listed multiple times. 1 time each item , each invoice number , item. how can alter query show client name 1 time corresponding totals of invoices combined?

i have lines 3 , 4 comments of think next can work in steps before fine tuning query desired output.

thanks

select customer.custname, sum(invoiceitem.quantity*item.itemprice) totalvalue client inner bring together invoice on customer.custabn = invoice.custabn inner bring together invoiceitem on invoice.invoiceno = invoiceitem.invoiceno inner bring together item on invoiceitem.itemno = item.itemno grouping customer.custname

sql oracle

No comments:

Post a Comment