Employees
emp_id, first_name, last_name, job_id, salary
Salary_Grade
grade, min_salary, max_salary
Here the salary field in the Employees table is joined on a range of minimum and maximum salaries in the Salary_Grade table, join conditions which do not match.emp_id, first_name, last_name, job_id, salary
Salary_Grade
grade, min_salary, max_salary
SQL> select E.last_name,E.salary,G.grade
2 from employees E INNER JOIN sal_grade G
3 on E.salary BETWEEN G.min_sal AND G.max_sal
4 order by G.grade;
The result is shown below:2 from employees E INNER JOIN sal_grade G
3 on E.salary BETWEEN G.min_sal AND G.max_sal
4 order by G.grade;
LAST_NAME SALARY G
------------------------- ---------- -
Philtanker 2200 A
Markle 2200 A
Olson 2100 A
Gee 2400 A
Landry 2400 A
Perkins 2500 B
Himuro 2600 B
Matos 2600 B
OConnell 2600 B
Grant 2600 B
Mikkilineni 2700 B
Although not very common, there are some situations where a non-equi join makes sense.
------------------------- ---------- -
Philtanker 2200 A
Markle 2200 A
Olson 2100 A
Gee 2400 A
Landry 2400 A
Perkins 2500 B
Himuro 2600 B
Matos 2600 B
OConnell 2600 B
Grant 2600 B
Mikkilineni 2700 B
No comments:
Post a Comment