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

T-SQL Tuesday Live–7 Apr 2020

By

Last week went a little crazy, and I learned something: don’t post a Zoom...

Getting Your dbatools Version–#SQLNewBlogger

By

Another post for me that is simple and hopefully serves as an example for...

SQL Server and VMware Resource Pools

By

Resource pools are used to hierarchically partition available CPU and memory resources, and are...

Read the latest Blogs

Forums

Tools for DISA's SQL Server STIGs

By aborelli1

Is it possible to request a review of a tool I created to automate...

bcp format file and import fixed width text file

By smattiko83

I'm trying to set up a format file using bcp but I'm unsure of...

insert random value from predefined list of possible values

By marchello

Hi all, My need is to insert random value from predefined list of possible...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers

Question of the Day

Linux Support

See possible answers