0

When I run the below query:

select PRECENTILE_CONT(0.5) WITHIN GROUP (ORDER BY X) AS MEDIAN_X
from table;

I get the following error:

Function 'PRECENTILE_CONT' is not an analytic aggregate but is called with a window spec

Please let me know if you have a solution to this.

Tharif
  • 13,794
  • 9
  • 55
  • 77
Macopare
  • 155
  • 1
  • 3
  • 11

2 Answers2

2

The function should be PERCENTILE_CONT. A typo i guess.

Vamsi Prabhala
  • 48,685
  • 4
  • 36
  • 58
  • I thought the keyword was PRECENTILE_CONT and didn't bother to think it as a typo. Also, the weird error message didn't help.But it turns out, it is a typo! Thanks. – Macopare Aug 05 '15 at 16:16
1

Re-arrange the syntax of query as below :

select PERCENTILE_CONT ( 0.5 ) 
WITHIN GROUP ( ORDER BY x )
OVER ( [ <partition_by_clause> ] ) as MEDIAN_X from table
Tharif
  • 13,794
  • 9
  • 55
  • 77
  • Thanks for this but just so you know I got the following error when I modified to this. 'PERCENTILE_CONT' is not a window function and cannot be used with the over() clause – Macopare Aug 05 '15 at 16:18