Site icon Web Sites Galour

SQL Excercise can’t understand join queries. HELP ME PLEASE [closed]

Hi guys someone could please help me? I really can’t understand “join”‘s… Given the database defined by the following relational schema:

Employee (id_code, Name, Surname, Serial Number, Unit, Prog) Project (ProjectCode, Name) Unit (UnitCode, Name, Headquarters)

Where the underlined attribute represents the primary key, the Unit attribute is the foreign key of the Unit and the Prog attribute is the foreign key of the Project.

express the following questions:

  1. Select employees with surname ‘Bianchi’
  2. Select the list of employee surnames in alphabetical order and without duplicates
  3. Select the locations of the units of employees who are assigned to the project with code ‘4’
  4. Count the employees assigned to each project for each unit

Those are the first two that I’ve done.

1)

SELECT *
FROM Employee
WHERE Surname= ‘Bianchi’;
 SELECT DISTINCT Surname
 FROM Employee
 ORDER BY Surname ASC;

Hope those two are at least correct

Exit mobile version