SELECT t1.person_id, t1.name, t1.state, t1.company, t3.dept_0, t3.dept_1, t3.title, t3.city FROM ( SELECT ROW_NUMBER() OVER (PARTITION BY person_id ORDER BY effect DESC, syseffect DESC) AS rid, person_id, name, state, landed, `type`, company FROM tb_person WHERE landed <= '20230630') t1 WHERE t1.rid = '1' AND t1.`type` = '入职' LEFT JOIN (SELECT t2.person_id, t2.dept_0, t2.dept_1, t2.title, t2.city FROM ( SELECT ROW_NUMBER() OVER (PARTITION BY person_id ORDER BY effect DESC) AS rid, person_id, name, landed, dept_0, dept_1, city, title FROM tb_dept WHERE landed <= '20230630') t2 WHERE t2.rid = '1') t3 ON t1.person_id = t3.person_id报错了
时间: 2024-04-10 17:32:13 浏览: 88
SELECT 语句的例子
根据你提供的 SQL 查询语句,报错的原因可能是在 WHERE 子句中使用了引号引起的字符串值。在 SQL 中,字符串值应该使用单引号('')或者双引号("")括起来。请检查以下部分的引号使用:
1. `WHERE t1.rid = '1' AND t1.`type` = '入职'`
2. `WHERE t2.rid = '1'`
请确保这些地方的引号使用正确,如果问题仍然存在,请提供具体的错误信息,以便更好地帮助您解决问题。
阅读全文