【问题标题】:NVL function in OracleOracle 中的 NVL 函数
【发布时间】:2018-03-15 10:49:28
【问题描述】:

我想从表employee中选择所有数据并与另一个表进行内部连接,例如:

SELECT * FROM EMPLOYEE 
INNER JOIN Deparment ON Employee.Id_Department = Deparment.Deparment_Id 
    AND NVL('Mathematics', Deparment.Name);

当我执行时,我得到一个错误ORA-00920: Invalid relational operator,我认为nvl() 函数可能是这里的问题。

【问题讨论】:

  • 你想从 AND NVL('Mathematics', Deparment.Name) 得到什么数据?

标签: sql oracle nvl


【解决方案1】:

您需要在NVL('Mathematics', Deparment.Name) 之后添加一个关系运算符,例如=, !=, <
举个例子:

AND NVL(Deparment.Name,'Mathematics')='Physics'

【讨论】:

    【解决方案2】:

    你没有在join语句中提到第二个条件NVL()函数参数放错了位置。 通过假设员工部门名称为department_name 并根据您的需要更改脚本来尝试此操作

    SELECT *
    FROM   employee
           inner join deparment
                   ON employee.id_department = deparment.deparment_id
                      AND employee.department_name =
                          NVL(deparment.name, 'Mathematics');  
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-15
      • 2017-11-06
      • 2012-12-09
      相关资源
      最近更新 更多