Skip to content

feat(sql): add difference and non_negative_difference sql functions#6858

Open
sanderson wants to merge 3 commits intomasterfrom
sql-difference-fn
Open

feat(sql): add difference and non_negative_difference sql functions#6858
sanderson wants to merge 3 commits intomasterfrom
sql-difference-fn

Conversation

@sanderson
Copy link
Copy Markdown
Collaborator

Summary

Adds documentation for difference and non_negative_difference SQL functions.

Checklist

  • Rebased/mergeable
  • Local build passes (npx hugo --quiet)

@sanderson sanderson requested a review from mhilton February 20, 2026 21:10
@sanderson sanderson requested a review from a team as a code owner February 20, 2026 21:10
@sanderson sanderson requested review from jstirnaman and removed request for a team February 20, 2026 21:10
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 20, 2026

PR Preview Action v1.4.8
🚀 Deployed preview to https://influxdata.github.io/docs-v2/pr-preview/pr-6858/
on branch gh-pages at 2026-04-21 19:04 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 20, 2026

📦 PR Preview — Preview Bot

Status Details
Result ✅ DEPLOYED
Preview View preview
Pages 5 page(s) deployed
Build time 71s
Last updated 2026-04-21 19:04:05 UTC
Pages included in this preview
  • /influxdb3/enterprise/reference/sql/functions/window/
  • /influxdb3/core/reference/sql/functions/window/
  • /influxdb3/cloud-serverless/reference/sql/functions/window/
  • /influxdb3/clustered/reference/sql/functions/window/
  • /influxdb3/cloud-dedicated/reference/sql/functions/window/

Preview auto-deploys on push. Will be cleaned up when PR closes.

{{% show-in "cloud-serverless,cloud-dedicated" %}}
### difference

Returns the result of subtraction between subsequent values.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the crucial bit of information that makes this different to using something like (c - LAG(c, 1)) OVER (...) is that it will skip over any number of NULL values to find the previous value to take the difference from.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the crucial bit of information that makes this different to using something like (c - LAG(c, 1)) OVER (...) is that it will skip over any number of NULL values to find the previous value to take the difference from.

@claude Update difference to make this distinction clear:
it uses the last previous non-NULL value to calculate the difference.

@jstirnaman jstirnaman added release:pending Waiting for product release before merging and removed Pending Release labels Mar 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Vale Style Check Results

Metric Count
Errors 0
Warnings 0
Suggestions 0

Check passed

@github-actions github-actions Bot added product:shared Shared content across products product:v3-distributed InfluxDB 3 Cloud Serverless, Cloud Dedicated, Clustered product:v3-monolith InfluxDB 3 Core and Enterprise (single-node / clusterable) labels Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:shared Shared content across products product:v3-distributed InfluxDB 3 Cloud Serverless, Cloud Dedicated, Clustered product:v3-monolith InfluxDB 3 Core and Enterprise (single-node / clusterable) release:pending Waiting for product release before merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants