Structured query language (SQL) for statistical process control

The latest version of the Structure Query Language (SQL) query provides the framework for creating Statistical Process Control (SPC) Individual Moving Range (XmR) charts. The accompanying Excel tool allows you to view, format, and export the SPC charts generated by the SQL query.

Both can be downloaded from the Making Data Count FutureNHS Collaboration Platform workspace.

The following functionality is included:

  • setting baselines
  • recalculating limits
  • improvement direction of up, down, and neither
  • identification of special cause variation
  • custom special cause settings
  • ghosting
  • variable targets
  • variation and assurance icons
  • icon summary table
  • chart annotations
  • chart formatting and exporting
  • warnings for potential errors or SPC misuse

The SQL query is prepopulated with sample data, allowing you to execute the query instantly. Clear guidance is provided, instructing you where and how to modify the query for your local data.

The Excel tool is also prepopulated with the same sample data.

Both files are provided as is. You must assure that when you modify for your own data, you are confident the SPC XmR chart is showing the correct and meaningful message.

You can find out more about correct calculation and interpretation of an SPC chart in Making Data Count.

If you have any comments or feedback, please email

Statistical process control icons in SQL