2017-02-22 6 views
2

이 코드를 실행하려고하는데, 나는 전혀 이해할 수없는 row_number() 표현에서 뭔가를 놓치고 있다고 말합니다.ORA - 00936 오류가 있지만 라인 2에서 누락 된 것을 찾을 수 없습니다.

with summary as 
(select s.city, length(s.city) as C_length, 
row_number() over (partition by length(s.city), order by s.city) 
as r1 from station s 
where 
length(s.city) = (SELECT min(LENGTH(s1.CITY)) FROM STATION s1) 
or length(s.city) = (SELECT max(LENGTH(s2.CITY)) FROM STATION s2)) 
select su.city, su.C_length 
from summary su; 
+0

'r1'을 사용하지 않으므로 계산할 필요가 없습니다. –

답변

2

partition by 절과 order by 절 사이에 쉼표가 안된다. 그냥 제거하고 확인해야합니다 :

row_number() over (partition by length(s.city) order by s.city) 
-- Comma removed here ------------------------^ 
+1

대단히 감사합니다. 그렇게 할 것입니다 – Vish

1

귀하의 쿼리를 단순화 할 수 있습니다

with summary as (
     select s.city, length(s.city) as C_length, 
      min(length(s.city)) over() as min_length, 
      max(length(s.city)) over() as max_length, 
     from station s 
    ) 
select su.city, su.C_length 
from summary su 
where c_length in (min_length, max_length); 

내가 r1를 제거 사용하지 않을 때문이다.

+0

고맙습니다. 그래서 min (length (s.city)) over() min_length가 작동할까요? 당신은 suring이라고 불리는 funtion을 "over()"라고 설명 할 수 있습니까? – Vish

+1

@Vish. . . 나는 당신의 의견을 이해하지 못합니다. 이 코드는 모든 데이터에 대해 도시의 최소 길이를 계산합니다. –

+0

필자는 paranthesis가 그 안쪽에 아무것도 넣지 않았 음을 의미합니까? – Vish