Trending today

1

Create a deep RPG character backstory with motivations, flaws, and arc potential

11.8K views
2

Anomaly detection with rolling z-score windows in SQL

11.8K views
3

30-day social media content calendar with post templates

11.6K views
4

Structured logging with correlation IDs across microservices

11.4K views
5

Legacy JavaScript to modern ES2023 refactor

10.9K views

Creators to follow

N
nadia_ux45 followers
D
david_ops45 followers
P
priya_design44 followers
AboutTermsPrivacyHelp

© 2026 teliprompt

NE
neil_stats
3 days ago•
Data & Analytics

Anomaly detection with rolling z-score windows in SQL

Claude Opus 4.6
code output
#sql
#anomaly-detection
#z-score
#monitoring
#statistics
Views
11.8K
Copies
2.5K
Likes
1.2K
Comments
0
Copy rate
21.0%

Prompt

You are a data scientist. Write a SQL anomaly detection query in [sql_dialect] for the metric [metric_name] in table [metrics_table] (columns: ts, value).

Use a rolling z-score over a [window_size]-row lookback window.

Requirements:
1. Compute rolling mean and stddev (exclude the current row from the baseline)
2. Produce a z-score, a boolean is_anomaly flag using threshold [z_threshold]
3. Classify anomalies as 'spike' or 'dip'
4. Suppress flags when stddev is near zero to avoid false positives on flat segments
5. Return only the most recent 30 days, with anomalies at the top

Customise this prompt

Fill in 5 variables to personalise this prompt

Preview
You are a data scientist. Write a SQL anomaly detection query in [sql_dialect] for the metric [metric_name] in table [metrics_table] (columns: ts, value). Use a rolling z-score over a [window_size]-row lookback window. Requirements: 1. Compute rolling mean and stddev (exclude the current row from the baseline) 2. Produce a z-score, a boolean is_anomaly flag using threshold [z_threshold] 3. Classify anomalies as 'spike' or 'dip' 4. Suppress flags when stddev is near zero to avoid false positives on flat segments 5. Return only the most recent 30 days, with anomalies at the top

Example output

Related prompts

A/B test significance calculator with practical interpretationby @neil_stats
Data & Analytics
Data catalog entry template that actually gets usedby @sunita_etl
Data & Analytics
GDPR data privacy audit checklist with implementation guideby @rachel_data
Data & Analytics
Python data visualization from raw data with chart selection guideby @viktor_ml
Data & Analytics