Aggregates

Optimize Your SQL by Reformulating the Spec

  • Article

As SQL developers, we tend to think of performance tuning in terms of crafting the best table indices, avoiding scalar and table valued functions, and analyzing query plans (among other things). But sometimes going back to the spec and applying some properties of elementary math can be the best way to begin to improve performance of SQL queries which implement mathematical formulas. This article is a case study of how I used this technique to optimize my SQL implementation of the Inverse Simpson Index.

5 (2)

2019-09-12

2,699 reads

Script to calculate the Median value for SQL Server data

  • Article

The standard SQL language has a number of aggregate functions like: SUM, MIN, MAX, AVG, but a common statistics function that SQL Server does not have is a built-in aggregate function for median. The median is the value that falls in the middle of a sorted resultset with equal parts that are smaller and equal parts that are greater. Since there is no built-in implementation for the median, the following is a simple solution I put together to find the median.

2011-11-08

2,817 reads

Blogs

SQLOrlando 2019

By

We just had our final event of the year and looking back, not bad...

New Power BI Report Design Pre-Con in 2020

By

I’m excited to announce that I will be offering a full-day pre-con about Power...

Read the latest Blogs

Forums

From Source Control to Database using SQL Compare Command Line

By Additional Articles

Comments posted to this topic are about the item From Source Control to Database...

The Schema Name

By Steve Jones - SSC Editor

Comments posted to this topic are about the item The Schema Name

The Login Types

By Steve Jones - SSC Editor

Comments posted to this topic are about the item The Login Types, which is...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers