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

SQL Queries Does the company offer any products that it has not sold? If yes, wh

ID: 3734608 • Letter: S

Question

SQL Queries

Does the company offer any products that it has not sold? If yes, what products have not been sold?

The above can include answering the following questions:
How many different products (differentiated by productCode) does the company have?
How many different products (differentiated by productCode) have been ordered?

What is the productLine and textDescription for the product lines in which the products that have not sold belong? (if there are any)

A sales manager is interested in how (or if) the priceEach for products ordered changes over time. Create a query that lists the productCode and priceEach for all the orders and order the results by productCode and priceEach. The ordering of the productCode is ascending and of the priceEach is descending.

Company Database Schema Table: customers # Name Type int(11) varchar(50) latin1_swedish c varchar(50) latin1_swedish_ci varchar(50) latin1_swedish_ci varchar(50) latin1 swedish_o varchar(50) latin1 swedish ci varchar(50) atin1_swedish c varchar(50) latin1_swedish_ci varchar(50) latin1 swedish_o varchar(15) latin1_swedish_ci varchar(50) latin1 swedish c Collation Attributes Null Default Extra 1 customerNumber 2 customerName 3 contactLastName 4 contactFirstName 5 phone 6 addressLinet 7 addressLine2 8 city 9 state No None No None No None No None No None No None Yes NULL No None Yes NULL Yes NULL No None Yes NULL Yos NULL 10 postalCode 11 country 12 salesRepEmployeeNumber int(11) 13 creditLimit decimal(10,2) Table: employees # Name 1 employeeNumber int(11) 2 lastName 3 firstName 4 extension 5 email 6 officeCode 7 reportsTo 8 jobTitle Type Collation Attributes Null Default Extra varchar(50) latin1_swedish_ci varchar(50) latin1_swedish_ci varchar(10) latin1_swedish_ci varchar 100) latin1_swedish_ci varchar(10) latin1_swedish_ci int(11) varchar(50) latin1_swedish_ci No None No None No None No None No None No None Yes NULL No None

Explanation / Answer

select p.productCode, od.priceEach from orderdetails od, products p order where p.productCode=od.productCode order by productCode asc, priceEach desc        // This will list the product code and price each for all orders and order the results by product code and price Each.