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

SQL 1 - Create a query that shows for every customer which sales person they pur

ID: 3857201 • Letter: S

Question

SQL

1 - Create a query that shows for every customer which sales person they purchased from, the number of times they ordered from this sales person, and the total amount due for their purchases. Sort by customer ID, name each column. (Sales.SalesOrderHeader) (860 rows)

2 - Show the total sales income for all sales persons and the number of sales they made. (Sales.SalesOrderHeader) (17 rows)

3 - Find the number of sales for each sales person where the total due for a order was over 100000. (Sales.SalesOrderHeader) (13 rows)

4 - Show the Maximum, minimum, and average for total sales by all sales person for last year(The table has a column for Sales Last Year). (Sales.SalesPerson)

5 - Find the number of employees born in the month of November. (HumanResources.Employee)(1 row)

6 - Find the number of employees that are paid at each rate and pay frequency. (Rate and PayFrequency are columns in the table)(HumanResources.EmployeePayHistory) (67 rows)

I don't have it.

Explanation / Answer

CREATE TABLE Sales( customer_name char(20), sales_person char(20),no_of_order Numeric, Customer_ID Numeric, amount int,lastyrsales PRIMARY KEY(Customer_ID ) );

2)

3)SELECT COUNT (DISTINCT sales_name) FROM Sales WHERE dueorder >100000

4) SELECT avg(lastyrsales),min(lastyrsales),max(lastyrsales) FROM Sales

5)SELECT count(Employee_name) FROM Employee WHERE month_of _born="November"

6)SELECT count ( DISTINCT rate_payfrequency) FROM Employee_pay_history