Hello all!
First I should specify that the problem is happening on redash using PostgreSQL databases.
Now, I’m currently trying to set up alerts for specific queries in order for us to control the validity of our data.
In order to do so I made queries using the results from specific queries in order to be able to have one column to set up alerts for. In the query I’m using the aggregating function percentile_disc
which allows you to select the percentile of your choice, and I’ve used it many times before without any issues.
But this time around I got a weird syntax error around the bra part of brackets: Error running query: **near "(": syntax error**
. After checking too many times for my sanity the syntax and not finding any issues I am now asking you.
The query looks like that:
SELECT percentile_disc (0.25) within group(
ORDER BY diff) AS firstquart,
percentile_disc (0.75) within group(
ORDER BY diff) AS thirdquart
FROM query_581
I also tried this format:
WITH main AS
(SELECT diff
FROM query_581
WHERE currency = ‘INR’),
percentiles AS
(SELECT percentile_disc (0.25) within group(
ORDER BY diff) AS firstquart,
percentile_disc (0.75) within group(
ORDER BY diff) AS thirdquart
FROM main)
SELECT *
FROM percentiles
And I tried a few other formats, deleting as many brackets as I could, as well as other aggregating functions like avg()
or sum()
. I was able to pinpoint the problem to the percentile functions. And I believe it is linked to maybe a specific syntax associated with queries using existing query results?
In any case I couldn’t find any previous cases of this happening and no help.
Thank you in advance if you have an insight on or a solution for that problem!