I'm using this SQL to determine the median of a group of temperatures...
select x.TEMP from QGPL/WEATHER1 x, QGPL/WEATHER1 y
group by x.TEMP
having sum(case when y.TEMP <= x.TEMP then 1 else 0 end)
sum(case when y.TEMP >= x.TEMP then 1 else 0 end)>= count(*)/2 + 1
If I want the 1st quartile, why couldn't I use the same code but insert a WHERE statement that selects only those values < the value returned from the first SQL? If I want the 3rd quartile, select only those values > value returned from first SQL?
If so, how do I modify the statement to include that WHERE statement?