Hello,
I got perhaps a silly question, but I can't seem to figure it out.
I want to do a query on invoices.
There are 2 tables: a table with the invoiceID, the NumberofHoursWorked and the SalaryPerHour
The other table contains Material (with a price and the number of items) for each invoice.
Obviously, an invoice can contain several items, and an item can appear on many invoices.
The query I want to do is as simple as this: Calculate the total amount of the invoice
Total Labor cost = NumberOfHoursWorked * SalaryPerHour
Total Material cost = sum of the cost of all items (item price * number of items)
Tax: (Total Labor cost + Total Material Cost) * Tax percentage
That all works fine, but when I do the query, I got the Total Labor Cost for each of the material items
so InvoiceID 1 with 3 items, would count the Total Labor Cost 3 times
It probably has something to do with group by and stuff, but it's not working...
any ideas?