samedi 25 avril 2015

Customer and branch query in company database


I have following four tables in my database :

EMPLOYEE

PK: employeeID;     
FK: empBranch references BRANCH;
FK: empSupervisor references EMPLOYEE

enter image description here

BRANCH

PK: branchNumber
FK: branchManager references EMPLOYEE

enter image description here

CUSTOMER

PK: customerID

enter image description here

ORDERS

PK: orderNumber
FK: customerID references CUSTOMER; 
FK: salesPerson references EMPLOYEE

enter image description here

Now I need to list out these two things :

  1. The Employee_ID and name of salespersons who have sold only to customers located in the same city as the city in which the salesperson’s branch is located.

  2. The Employee_ID and name of salespersons who have sold to every customer located in the same city as the city in which the salesperson’s branch is located.

Please help me to answer both queries


Aucun commentaire:

Enregistrer un commentaire