Reverted a few changes to optimize the quartile queries.  use Count_BIG(*) instead of COUNT_BIG(datediff) when possible.