SQL

MEDIAN: For When You Don't Really Mean It

MEDIAN: For When You Don't Really Mean It

Median is a measure of central tendency useful in describing the typical experience, or the typical case. It's a type of average along with the mean, but less susceptible to skew from outlying values. Median is useful in describing, say, what the typical sale looks like, or what the typical customer is likely to spend.

STDDEV: Standing Sentinel on Your Data

STDDEV: Standing Sentinel on Your Data

Oracle Database implements a family of STDDEV functions for computing the standard deviation from the mean. If you think of the mean as beginning to paint a picture of the underlying data, then standard deviation is another brush-stroke toward a fuller picture that will help you draw meaning from the data you're studying.

AVG: What Does it Mean?

AVG: What Does it Mean?

AVG is an aggregate function in SQL to compute the "average" of a set of values. More precisely, it computes the mean of those values. And even more precisely, AVG computes what is known as the arithmetic mean. But keep reading! Learning about "average" is like uncovering an iceberg. There's more to it than meets the eye.

You've Got Framing

You've Got Framing

The framing clause brings the "window" to window functions. It's an ideal solution when you can arrange a business question such that an answer comes from applying an aggregate function to a range of rows that slides or stretches smoothly as focus moves from one row to the next. Running sums and moving averages are just two examples of such problems. 

Pulling Rank for the Boss

Pulling Rank for the Boss

Look to ROW_NUMBER, RANK, and DENSE_RANK anytime you are faced with a business question involving words or phrases such as "topmost" or "bottommost", "top N" or "bottom N", or that is otherwise answerable by ranking the rows in a result set according to some criteria that you can apply to one or more columns of data.

H. G. Wells and SQL: Traveling in the Second Dimension

H. G. Wells and SQL: Traveling in the Second Dimension

SQL is traditionally one-dimensional in that you can access values in a row, in the horizontal dimension. SQL Server 2012's support of LAG and LEAD and other so-called window functions open up the vertical dimension, giving access to all values in a column.