Median absolute deviation for time series outlier detection in Amazon Redshift
I believe this is very doable with a CTE or subquery!

MAD is can be calculated by composing several Redshift functions:


the median of a list of values
absolute value of the difference between each value and that median
the median of those values


I wrote this in the form of:

WITH
medians AS (
  SELECT
    t.values,
    MEDIAN(t.values) OVER () as median_value,
    ABS(t.values-MEDIAN(t.values) OVER ()) AS absolute_deviation
  FROM table AS t
  GROUP BY t.values
)
SELECT
  MEDIAN(absolute_deviation) OVER () AS median_absolute_deviation
FROM medians


Hope this helps