Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the following in SQL statements As an example, if the question was 1. How many different products does the company have? The SQL

image text in transcribedimage text in transcribedWrite the following in SQL statements

As an example, if the question was "1. How many different products does the company have?"

The SQL statement to answer that question would be:

SELECT COUNT(DISTINCT(productCode)) FROM products;

1. How many employees does the company have?

2. How many different customers does the company have?

3. List the employees by name (in alphabetical ascending order using lastname and firstname for the ordering) and the city, state, and phone office information to which the employee is assigned.

4. What is the productCode, quantityOrdered, priceEach and orderDate for the last order placed?

5. What is the value of the largest payment ever made?

6. What is the value of the smallest payment ever made?

7. How many offices does the company have?

8. How many cities does the company have offices in?

9. What is the name (or names) of the customer (or customers) that have the highest credit limit and what is that credit limit?

10. 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?

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

12. 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.

Table: customers # Name Collation Type int(11) Attributes Null Default Extra No None 1 customer Number 2 customerName varchar(50) latin1_swedish_ci 3 contactLastName varchar(50) latin1_swedish_ci 4 contactFirstName varchar(50) latin1_swedish_ci 5 phone varchar(50) latin1_swedish_ci 6 addressLine1 varchar(50) latin1_swedish_ci 7 addressLine2 varchar(50) latin1_swedish_ci 8 city varchar(50) latin1_swedish_ci 9 state varchar(50) latin1_swedish_ci 10 postalCode varchar(15) latin1_swedish_ci 11 country varchar(50) latin1_swedish_ci 12 salesRepEmployeeNumber int(11) 13 creditLimit decimal(10,2) No None No None No None No None No None Yes NULL No None Yes NULL Yes NULL No None Yes NULL Yes NULL Table: employees # Name Type Collation Attributes Null Default Extra 1 employeeNumber int(11) No None 2 lastName varchar(50) latin1_swedish_ci No None 3 firstName varchar(50) latin1_swedish_ci No None 4 extension varchar(10) latin1_swedish_ci No None 5 email varchar(100) latin1_swedish_ci No None 6 officeCode varchar(10) latin1_swedish_ci No None 7 reports To int(11) Yes NULL 8 job Title varchar(50) latin1_swedish_ci No None Table: offices # Name Type Collation Attributes Null Default Extra 1 officeCode varchar(10) latin1_swedish_ci No None 2 city varchar(50) latin1_swedish_ci No None 3 phone varchar(50) latin1_swedish_ci No None 4 addressLine1 varchar(50) latin1_swedish_ci No None 5 addressLine2 varchar(50) latin1_swedish_ci Yes NULL Yes NULL 6 state varchar(50) latin1_swedish_ci 7 country varchar(50) latin1_swedish_ci No None 8 postalCode varchar(15) latin1_swedish_ci No None No None 9 territory varchar(10) latin1_swedish_ci Table: orderdetails Collation # Name 1 orderNumber 2 productCode Type int(11) varchar(15) int(11) decimal(10,2) latin1_swedish_ci Attributes Null Default Extra No None No None No None No None No None 3 quantityOrdered 4 priceEach 5 orderLineNumber smallint(6)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Write a letter asking them to refund your $1,500 down payment.

Answered: 1 week ago