Skip to content

Commit

Permalink
updated aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Clifford committed Aug 9, 2023
1 parent 317641c commit 0b984f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ type OwnProps = {
export const ExecuteAggregateQuerySql = (props: OwnProps) => {
const {bucket} = props

const sqlSnippet = `SELECT mean(count)
FROM census
WHERE time > now() - '10m'`
const sqlSnippet = `SELECT mean(ants) as ant_mean, mean(bees) as bee_mean
FROM census
WHERE time >= now() - 24h`

const querySnippet = `query = """SELECT mean(count)
FROM census
WHERE time > now() - '10m'"""
const querySnippet = `query = """SELECT mean(ants) as ant_mean, mean(bees) as bee_mean
FROM census
WHERE time >= now() - 24h"""
# Execute the query
table = client.query(query=query, database="${bucket}", language='influxql')
Expand All @@ -40,7 +40,7 @@ print(df)
<h1>Execute an Aggregate Query</h1>
<p>
<SafeBlankLink
href="https://docs.influxdata.com/flux/v0.x/function-types/#aggregates"
href="https://docs.influxdata.com/influxdb/cloud-serverless/reference/influxql/functions/aggregates"
onClick={logDocsOpened}
>
Aggregate functions
Expand All @@ -58,7 +58,7 @@ print(df)
<p>
In this example, we use the{' '}
<code className="homepage-wizard--code-highlight">mean()</code> function
to calculate the average value of data points in the last 10 minutes.
to calculate the average value of data points in the last 24 hours.
<br />
<br />
Run the following:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ export const ExecuteQuerySql = (props: OwnProps) => {

const sqlSnippet = `SELECT *
FROM census
WHERE time >= now() - interval '1 hour'
AND ('bees' IS NOT NULL OR 'ants' IS NOT NULL)`
WHERE time >= now() - interval '1 hour'`

const query = `query = """SELECT *
FROM census
WHERE time >= now() - interval '24 hours'
AND ('bees' IS NOT NULL OR 'ants' IS NOT NULL)"""
WHERE time >= now() - interval '24 hours'"""
# Execute the query
table = client.query(query=query, database="${bucket}", language='sql')
Expand Down

0 comments on commit 0b984f6

Please sign in to comment.