Skip to content

Instantly share code, notes, and snippets.

@randyzwitch
Created June 12, 2014 15:59
Show Gist options
  • Save randyzwitch/5de36f4a608f11895039 to your computer and use it in GitHub Desktop.
Save randyzwitch/5de36f4a608f11895039 to your computer and use it in GitHub Desktop.
Percentiles in Hive - Wrong Way
--Hive expects that you want to calculate your percentiles by account_number and sales
--This code will generate an error about a missing GROUP BY statement
select
account_number,
sales,
CASE WHEN sales > percentile_approx(sales, .9) THEN 1 ELSE 0 END as top10pct_sales
from sales;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment