diff --git a/docs/sources/datasources/mssql/query-editor/index.md b/docs/sources/datasources/mssql/query-editor/index.md index 82ef3581b3a..a50c05944db 100644 --- a/docs/sources/datasources/mssql/query-editor/index.md +++ b/docs/sources/datasources/mssql/query-editor/index.md @@ -236,12 +236,12 @@ To optionally customize the default series name formatting, refer to [Standard o ```sql SELECT - $__timeGroup(time_date_time, '5m') as time, + $__timeGroupAlias(time_date_time, '5m'), min("value_double"), 'min' as metric FROM test_data WHERE $__timeFilter(time_date_time) -GROUP BY $__timeGroup(time_date_time, '5m') +GROUP BY time ORDER BY 1 ``` @@ -260,18 +260,18 @@ Data frame result: ### Time series query examples -**Using the fill parameter in the $\_\_timeGroup macro to convert null values to be zero instead:** +**Using the fill parameter in the $\_\_timeGroupAlias macro to convert null values to be zero instead:** ```sql SELECT - $__timeGroup(createdAt, '5m', 0) as time, + $__timeGroupAlias(createdAt, '5m', 0), sum(value) as value, hostname FROM test_data WHERE $__timeFilter(createdAt) GROUP BY - $__timeGroup(createdAt, '5m', 0), + time, hostname ORDER BY 1 ``` @@ -295,12 +295,12 @@ Data frame result: ```sql SELECT - $__timeGroup(time_date_time, '5m'), + $__timeGroupAlias(time_date_time, '5m'), min(value_double) as min_value, max(value_double) as max_value FROM test_data WHERE $__timeFilter(time_date_time) -GROUP BY $__timeGroup(time_date_time, '5m') +GROUP BY time ORDER BY 1 ``` diff --git a/docs/sources/datasources/mysql/_index.md b/docs/sources/datasources/mysql/_index.md index 33ad8a30578..835cb3e7810 100644 --- a/docs/sources/datasources/mysql/_index.md +++ b/docs/sources/datasources/mysql/_index.md @@ -283,7 +283,7 @@ To optionally customize the default series name formatting, refer to [Standard o ```sql SELECT - $__timeGroup(time_date_time,'5m'), + $__timeGroupAlias(time_date_time,'5m'), min(value_double), 'min' as metric FROM test_data @@ -305,11 +305,11 @@ Data frame result: +---------------------+-----------------+ ``` -**Example using the fill parameter in the $\_\_timeGroup macro to convert null values to be zero instead:** +**Example using the fill parameter in the $\_\_timeGroupAlias macro to convert null values to be zero instead:** ```sql SELECT - $__timeGroup(createdAt,'5m',0), + $__timeGroupAlias(createdAt,'5m',0), sum(value_double) as value, hostname FROM test_data @@ -338,7 +338,7 @@ Data frame result: ```sql SELECT - $__timeGroup(time_date_time,'5m'), + $__timeGroupAlias(time_date_time,'5m'), min(value_double) as min_value, max(value_double) as max_value FROM test_data diff --git a/docs/sources/datasources/postgres/_index.md b/docs/sources/datasources/postgres/_index.md index 82db22b8908..ef3960fefe3 100644 --- a/docs/sources/datasources/postgres/_index.md +++ b/docs/sources/datasources/postgres/_index.md @@ -235,7 +235,7 @@ To optionally customize the default series name formatting, refer to [Standard o ```sql SELECT - $__timeGroup("time_date_time",'5m'), + $__timeGroupAlias("time_date_time",'5m'), min("value_double"), 'min' as metric FROM test_data @@ -257,11 +257,11 @@ Data frame result: +---------------------+-----------------+ ``` -**Example using the fill parameter in the $\_\_timeGroup macro to convert null values to be zero instead:** +**Example using the fill parameter in the $\_\_timeGroupAlias macro to convert null values to be zero instead:** ```sql SELECT - $__timeGroup("createdAt",'5m',0), + $__timeGroupAlias("createdAt",'5m',0), sum(value) as value, hostname FROM test_data @@ -290,7 +290,7 @@ Data frame result: ```sql SELECT - $__timeGroup("time_date_time",'5m'), + $__timeGroupAlias("time_date_time",'5m'), min("value_double") as "min_value", max("value_double") as "max_value" FROM test_data diff --git a/public/app/plugins/datasource/mysql/CheatSheet.tsx b/public/app/plugins/datasource/mysql/CheatSheet.tsx index 290b1d8f06b..febfdbdad2a 100644 --- a/public/app/plugins/datasource/mysql/CheatSheet.tsx +++ b/public/app/plugins/datasource/mysql/CheatSheet.tsx @@ -48,10 +48,10 @@ export function CheatSheet() {
  • $__timeGroupAlias(column,'5m') -> cast(cast(UNIX_TIMESTAMP(column)/(300) as signed)*300 as - signed) AS "e;time"e; + signed) AS "time"
  • $__unixEpochGroup(column,'5m') -> column DIV 300 * 300
  • -
  • $__unixEpochGroupAlias(column,'5m') -> column DIV 300 * 300 AS "e;time"e;
  • +
  • $__unixEpochGroupAlias(column,'5m') -> column DIV 300 * 300 AS "time"
  • Example of group by and order by with $__timeGroup:

    diff --git a/public/app/plugins/datasource/postgres/CheatSheet.tsx b/public/app/plugins/datasource/postgres/CheatSheet.tsx
    index b7403ced10c..8608b33cd81 100644
    --- a/public/app/plugins/datasource/postgres/CheatSheet.tsx
    +++ b/public/app/plugins/datasource/postgres/CheatSheet.tsx
    @@ -32,8 +32,8 @@ export function CheatSheet() {
           
           Macros:
           
           

    Example of group by and order by with $__timeGroup: