Anybody? Am i barking up the wrong tree?
Apr 29, 2015
4
Level 8
Pivot table sums?
How would i do calculations on data within a pivot table?
I have 3 tables:
Orders (id, date, customer_id) Order_Product (id, order_id, product_id, quantity, term, sell_price, buy_price) and Products (id, name)
I have setup a many to many relationship using the Order_product pivot table.
I'm stuck with how i would go about calculating the total contract value for example (sell_price * quantity * term) and returning this to the view?
Please or to participate in this conversation.