SQL throw"无效的标识符"错误

时间:2014-06-06 19:29:23

标签: sql oracle row-number where-in

以下查询会在别名' RANKING'上抛出"00904. 00000 - "%s: invalid identifier"错误。无法弄清楚为什么这不起作用。如果我消除了' WHERE'子句,它产生正确的结果。

SELECT RELEASE_NAME, 
 ROW_NUMBER() OVER(ORDER BY START_DATE DESC) AS RANKING
 FROM(
   SELECT RELEASE_NAME, MIN(START_DATE) AS START_DATE FROM RM_TASK_STATUS_VIEW
        WHERE RELEASE_NAME LIKE '%AU%' AND START_DATE IS NOT NULL
        GROUP BY RELEASE_NAME
        ORDER BY START_DATE
  ) 
WHERE RANKING IN (3,4);

1 个答案:

答案 0 :(得分:1)

创建查询的派生表,并将where子句放在最后。

select * from 
(your query, minus the where clause, goes here) temp
WHERE RANKING IN (3,4);