Skip to content

Instantly share code, notes, and snippets.

@kerbelp
Created December 20, 2016 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kerbelp/ab7f53667c4f98b83bd6cd2804e8128b to your computer and use it in GitHub Desktop.
Save kerbelp/ab7f53667c4f98b83bd6cd2804e8128b to your computer and use it in GitHub Desktop.
WITH total_count_calc AS
(
SELECT COUNT(*) AS total_count
FROM elb_logs_raw_partition
WHERE YEAR = '2016'
AND MONTH = '12'
AND DAY = '15'
),
status_count_calc AS
(
SELECT elb_response_code,
COUNT(*) AS status_count
FROM elb_logs_raw_partition
WHERE YEAR = '2016'
AND MONTH = '12'
AND DAY = '15'
GROUP BY elb_response_code
)
SELECT SUM(percentile) as success_percentile
FROM (SELECT elb_response_code,
status_count,
total_count,
status_count / CAST(total_count AS DOUBLE)*100 AS percentile
FROM status_count_calc
INNER JOIN total_count_calc ON 1 = 1)
WHERE elb_response_code IN ('200','204');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment