Assume that for each product, unit gross profit is defined as (unit price - cost
ID: 3708873 • Letter: A
Question
Assume that for each product, unit gross profit is defined as (unit price - cost of raw materials). Compose a query to display the unit gross profit of each product. Show Product ID, Product Name, and its corresponding unit gross profit in the result table. [Hint: you may need two queries to answer this question. The first query is used in the FROM clause of the second query].
Table1: Order_line_t
Table2 : Product_t
Table3: Raw_Materials_t
Order_line_t Order_ID Product_ID Quantity 1001 1 2 1001 2 2 1001 4 1 1002 3 5 1003 3 1 1004 6 2 1004 8 2 1005 4 4 1006 4 1 1006 5 2 1006 7 2 1007 1 3 1007 2 2 1008 3 2 1008 8 3 1009 4 2 1009 7 3 1010 8 10Explanation / Answer
Solution:
Query:
SELECT Product_ID, Product_Name, (Unit_Price-Cost_Raw_materials) AS profit FROM Product_t, (SELECT Cost_Raw_materials FROM Raw_Materials_t) GROUP BY Product_ID
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)