Q&A for those using, extending or developing Emacs
select PERCENTILE_DISC (0.5) WITHIN GROUP (order by datediff(hour, Q.CreationDate, Q.ClosedDate)) over () as median from Posts as Q where Q.PostTypeId = 1 and Q.CreationDate between '20170101' and '20171231';