Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Query 3 Solution --
- with mat_cost as
- (select u.product_id, SUM(u.goes_into_quantity * r.material_standard_cost) as total
- from csc342.uses u join csc342.raw_material r on u.material_id = r.material_id
- group by u.product_id),
- product_totals (product_id, product_standard_price) as
- (select p.product_id, p.product_standard_price
- from csc342.product p)
- select pt.product_id as "Product ID", p.product_description as "Product Name", TO_CHAr(ABS(pt.product_standard_price - mc.total),'$999,999.99') as "Profit Margin"
- from product_totals pt join mat_cost mc on pt.product_id = mc.product_id
- join csc342.product p on p.product_id = pt.product_id
- order by pt.product_id asc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement