0
help write SQL query
There are 3 entities in the database: FIO_person, Salary and JobPosition. 1) The FIO_person table contains attributes - ID (employee id), FIO (employee's full name) 2) The Salary table contains attributes - Salary_ID (id of the RFP entry), Person_ID (foreign key to table FIO_person), Value (employee salary) 3) The JobPosition table contains attributes - Position_ID (position record id), Person_ID (foreign key to FIO_person table), NamePosition (position title), Duration (number of years in position)
5 Answers
0
1)Display a list containing full name, salary, position and number of years in position for employees who have worked from 1 to 10 years.
2) Get a list of all full names of employees in the position of "Developer" with a salary greater than 10,000 rubles.
0
Show us how you have tried, please. Select x from y where z > t order by u etc.
0
SELECT FIO_person.FIO, Salary.Value, JobPosition.NamePosition, JobPosition.Duration
FROM FIO_person INNER JOIN Salary JobPosition
ON FIO_person.ID = JobPosition.Position_ID
WHERE Duration BETWEEN 1 AND 10
;
0
I think inner join works with only one table. Do you have to use it? The query can be solved without it.
SELECT columns FROM table1, table2, table3 WHERE table1.[person_]id = table2.person_id AND table2.person_id = table3.person_id etc. This is wrong: FIO_person.ID = JobPosiotion.Position_ID because the right key is the Person_ID, you write "foreign key to FIO_person table".
0
INNER JOIN can use to join multiple tables, join reference to the first table.
SELECT *
FROM FIO_person
INNER JOIN
Salary
ON
FIO_person.ID = Salary.Person_ID
INNER JOIN
JobPosition
ON
FIO_person.ID = JobPosition.Person_ID;