Question: SQL queries: 1. Returns all the employees and their average sales amount (of all the customers) for each of the products (query result: eid, pid

 SQL queries: 1. Returns all the employees and their average sales

SQL queries:

1. Returns all the employees and their average sales amount (of all the customers) for each of the products (query result: eid, pid and avg_sales). */

2. Returns the name and unit price of all the products (pname and unit_price) which are never ordered by 'Disney

3. Returns the products (pid and pname) which are sold by the direct manager(s) of employee '0013' and the quantity of any customer (not aggregated) is greater than 300.

Consider the following database schema and example instance: Emplovee Customer city state ei ename dobsalary 0011 Chris 01/03/1986 100,000 0012 Edward 07/24/1973 120,000 0013 Anna 08/12/1992 80,000 0014 Kim 08/26/1986 95,000 0015 Caro 04/15/1988 97,000 Ci cname A101 Chase New YorkNY CiiNew York NY A103 TD Bank Boston MA IL A105 DiyOrlandoFL A102 Moto Chicago Product pname unit_price C178 Desk C17812 Chair C23453 PC C31451Mac 500 200 1,200 1,300 Sales Manages eid cid pidquantity 0011 A101 C17811 0011 A102 C17812 0012 A102 C23453 0013 A101 C34451 eiddI eid2 700 200 100 50 0011 0013 0013 0017 0012 0013 Hints: . Underlined attribute(s) form the primary key of a relation Relation Sales stores the sales information: the salesman (employee ID) who is in charge of the ordered product, the product ID, the customer ID, and the quantities of ordered products. The attributes eid, cid and pid of relation Sales are the foreign keys to relations Employee (salesman), Customer and Product, respectively DB Fall 2018: Page 2 (of 15) Relation Manages stores the "managing" information in the company (e.g., the employee with eidl is the direct manager of the employee with cid2) All the IDs' are strings

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!