Oracle 18.1 SQL查询错误

时间:2018-08-29 19:12:17

标签: oracle oracle-apex

我有一个SQL查询

SELECT ("SL/VL".TOTAL_SICK_LEAVE - SUM(EMPLOYEE_INFO.DAYS_TAKEN_SICK))
  FROM EMPLOYEE_INFO
  INNER JOIN "SL/VL"
    ON EMPLOYEE_INFO.EMPLOYEE_NAME = "SL/VL".EMPLOYEE_NAME
  where contract_year='Year 1'and
        employee_info.EMPLOYEE_NAME = :P4_EMPLOYEE_NAME
  GROUP BY "SL/VL".TOTAL_SICK_LEAVE

当我使用oracle apex 5.1时,这给了我想要的结果。现在,我将数据库升级到oracle 18.1,我得到了"ORA-20999: Column name "("SL/VL".TOTAL_SICK_LEAVE-SUM(EMPLOYEE_INFO.DAYS_TAKEN_SICK))" is invalid for the LOV SQL query. Make sure that you use valid alias names for your columns."

1 个答案:

答案 0 :(得分:3)

看来18.1要在表达式("SL/VL".TOTAL_SICK_LEAVE - SUM(EMPLOYEE_INFO.DAYS_TAKEN_SICK))上使用列别名。也许如果您将SQL重做为

SELECT (s.TOTAL_SICK_LEAVE - SUM(e.DAYS_TAKEN_SICK)) AS SICK_LEAVE_REMAINING
  FROM EMPLOYEE_INFO e
  INNER JOIN "SL/VL" s
    ON e.EMPLOYEE_NAME = s.EMPLOYEE_NAME
  WHERE CONTRACT_YEAR = 'Year 1' AND
        e.EMPLOYEE_NAME = :P4_EMPLOYEE_NAME
  GROUP BY s.TOTAL_SICK_LEAVE

数据库会更快乐。