Created
June 12, 2014 15:59
-
-
Save randyzwitch/5de36f4a608f11895039 to your computer and use it in GitHub Desktop.
Percentiles in Hive - Wrong Way
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--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