How to Use percentile_cont in TSQL to Group Data by Upper, Middle, and Lower Thirds
In this episode, we’re going to learn how to assign a percentile group to each record in our table, so that we can see if the record is in the upper, middle, or lower rank of its set. We’ll use climate change data from the Work Bank Group, choosing three measures to analyze. These will include (a.) percentage of land lower than 5m, (b.) annual rainfall, and (c.) population. With these, we’ll be able to see which countries are in the top, middle, and lower 33% of all countries. This is great for pre-loading calculations for data warehouse tables. In many cases it is more convenient to perform these calculations BEFORE we load them into our analytics datasets in Power BI, Tableau, SSRS, or other tools. Performance of queries or calculations is generally faster on SQL Server, and sometimes it is just more convenient to have some calculations ready before analysis begins.
Doing analytics on SQL Server? Contact me today!