在sql中使用日期操作

时间:2014-05-17 12:10:18

标签: sql oracle

Hy,我是sql的新手,我正在努力让那些工作了整整几周的员工(整数)。我试过这个:

SELECT employee_id, last_name, salary
FROM employees
WHERE MOD(ROUND(SYSDATE – hire_date), 7) = 0;

但是我遇到了这个错误:

0911. 00000 -  "invalid character"
*Cause:    identifiers may not start with any ASCII character other than
           letters and numbers.  $#_ are also allowed after the first
           character.  Identifiers enclosed by doublequotes may contain
           any character other than a doublequote.  Alternative quotes
           (q'#...#') cannot use spaces, tabs, or carriage returns as
           delimiters.  For all other contexts, consult the SQL Language
           Reference Manual.
*

任何人都可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

你有一个" En Dash"你的where子句中的( - ,ascii代码150),而不是用作减法运算符的hypen( - ,ascii代码45)。

用正确的字符替换它,查询执行得很好:

SELECT employee_id, last_name, salary
FROM employees
WHERE MOD(ROUND(SYSDATE - hire_date), 7) = 0;