我试图更好地理解子查询,但下面的这个脚本有问题。(SQL Server 数据库)
SELECT division_name, business_name, assignment_code, assignment_desc, last_name, first_name, total_salary, assign_fte, birth_year
FROM table1 join
(SELECT division_name, last_name, first_name, assignment_code, emp_id
FROM table1) raw
WHERE raw.year_time = year_time
AND division_name <> raw.division_name
AND last_name = raw.last_name
AND first_name = raw.first_name
ORDER BY last_name, first_name
我需要做的是加入同一张表并提取员工为两个不同部门工作的数据。上面的代码在 where 子句附近有一个语法错误。