Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In SQL, create the query with the given instructions and the model below: Retrie

ID: 3874215 • Letter: I

Question

In SQL, create the query with the given instructions and the model below:

Retrieve a list of the customers of PVFC and the total profit earned from all of their orders.

Profit earned on a given order is the order total minus the total cost to produce the

products sold. The cost of production for a given product is the total cost of all raw

materials consumed in production. The query should output the customer ID, customer

name, total amount of all orders placed by the customer, total cost of production of all

products sold in these orders, and total dollars profit earned. Sort the results in descending

order of profit.

FIGURE 2-22 Data model for Pine Valley Furniture Company in Microsoft Visio notation SALESPERSON TERRITOR SIN PK Salesperson ID Serves PK Territory ID Salesperson Name Salesperson Telephone Salesperson Fax Territory Name CUSTOMER PRODUCT LINE PK Customer ID PK Product Line ID Customer Name Customer Address Customer Postal Code Product Line Name Submits Includes ORDER PK Order ID Order Date DUC ORDER LINE PK Product ID Product Description Product Finish Product Standard Price Ordered Quantity VENDOR USES PRODUCED IN PK Vendor ID Vendor Name Vendor Address Goes Into Quantity RAW MATERIAL WORK CENTER PK Material ID PK Work Center ID Material Name Material Standard Cost Unit Of Measure Work Center Location Supply Unit Price ls Supervised By EMPLOYEE WORKS IN SupervisesPEmployee ID HAS SKILL SKILL Employee Name Employee Address PK Skill

Explanation / Answer

1.

2.

SELECT EXTRACT( MONTH FROM datesold ) AS mnth,

       SUM( SalesPrice - AcquisitionPrice ) AS profit

FROM   Transaction

WHERE EXTRACT( YEAR FROM datesold ) = 2009

GROUP BY EXTRACT( MONTH FROM datesold )

ORDER BY EXTRACT( MONTH FROM datesold ) DESC

Please go through that your picture is not clearly visible so I have tried to obtain a general query for both the scenarios.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote