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,792 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

Daily Coping 2 Jul 2020

By

I’ve started to add a daily coping tip to the SQLServerCentral newsletter and to...

Presenting on Ethics in Modern Data at Houston HASSUG/SQL BI Group July 2020 Meeting

By

Looking forward to presenting with my wife Christine Assaf our talk on Ethics in...

MVP for Another Year 2020-2021

By

Early this afternoon I received an email from Microsoft presenting me with the 2020-2021...

Read the latest Blogs

Forums

Unusual use of the WHERE clause

By michael.leach2015

I am working an exercise problem where the solution provided has a WHERE clause...

How to get the SSAS Server administrators in MDX query?

By sabarishbabu

Hello, Is there any way to get the list of server administrators from SSAS...

Upgrading from SQL Server 2012 to SQL Server 2017 - Any Tips or Gotchas

By HookSQLDBA7

We are running SQL Server 2012 SP4 Standard Edition on Windows Server 2012 R2...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers