Using frequency tables to understand discrete variables

For an overview of discrete variables, you use frequency tables and charts. A frequency table can show the following:

  • The values
  • The count of the values, or the absolute frequency
  • The proportion of the value, or the absolute percentage
  • The cumulative frequency
  • The cumulative percent
  • Plus, you can create a bar chart or a histogram of the values' absolute percentage

Minimally, you need to calculate the counts of the distinct values of the variable.

Let me start with calculating the frequencies with T-SQL. Window aggregate functions are very handy here. The following query is a very efficient one. If you look at the first part of the query, you'll notice that there is a common table expression ...

Get Data Science with SQL Server Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.