# \#sql

**URL:** https://community.grafana.com/tag/sql/284.md

[Latest](https://community.grafana.com/latest.md) · [Categories](https://community.grafana.com/categories.md) · [Tags](https://community.grafana.com/tags.md)

---

## [Hide Data outside timerange message?](https://community.grafana.com/t/hide-data-outside-timerange-message/123715)

<div class="topic-metadata">

**Author:** [@tadeasvintrlik1](https://community.grafana.com/u/tadeasvintrlik1)\
**Replies:** 2\
**Last updated:** [August 17, 2026, 2:43am UTC](https://community.grafana.com/t/hide-data-outside-timerange-message/123715 "2026-08-17T02:43:15Z")

</div>

I am using Grafana v10.4.1. I use the PostgreSQL datasource. I am using it to connect to our build system’s database (buildbot). This contains information about build results. I am using a query like this SELECT bu…

---

## [MySQL timezone conversion: interval Europe/Paris failed](https://community.grafana.com/t/mysql-timezone-conversion-interval-europe-paris-failed/163426)

<div class="topic-metadata">

**Author:** [@enguerranhv](https://community.grafana.com/u/enguerranhv)\
**Replies:** 4\
**Last updated:** [June 26, 2026, 12:06pm UTC](https://community.grafana.com/t/mysql-timezone-conversion-interval-europe-paris-failed/163426 "2026-06-26T12:06:22Z")

</div>

Hello, for my panel i need to transform my time into an other time zone, in previous panel i used but in France UTC+2 became UTC+1 in december, so i cant just use UTC+2 I use a mysql datasource i use the line under…

---

## [Parsing MSSQL ERRORLOG in UTF-16LE BOM encoding](https://community.grafana.com/t/parsing-mssql-errorlog-in-utf-16le-bom-encoding/161370)

<div class="topic-metadata">

**Author:** [@bdein](https://community.grafana.com/u/bdein)\
**Replies:** 4\
**Last updated:** [February 13, 2026, 9:56pm UTC](https://community.grafana.com/t/parsing-mssql-errorlog-in-utf-16le-bom-encoding/161370 "2026-02-13T21:56:09Z")

</div>

Hi, I see some closed cases related to this issue: Need help specifying log path for MSSQL MSSQL servers logs extracted to loki Grafana dashboard with space in between character’s Which I’m having a hard time to unde…

---

## [$\_\_timeGroup +2hrs in aggregation per day](https://community.grafana.com/t/timegroup-2hrs-in-aggregation-per-day/148543)

<div class="topic-metadata">

**Author:** [@snowpg](https://community.grafana.com/u/snowpg)\
**Replies:** 12\
**Last updated:** [January 29, 2026, 3:37am UTC](https://community.grafana.com/t/timegroup-2hrs-in-aggregation-per-day/148543 "2026-01-29T03:37:07Z")

</div>

What do you see: SELECT $\_\_timeGroup(timestamp, ‘1d’) AS time, sum(value) as value, Measures as metric FROM \[Data\] where $\_\_timeFilter(timestamp) group by $\_\_timeGroup(timestamp, ‘1d’), Measures ORDER BY 1 ASC I…

---

## [Grafana Table – Conditional cell color based on comparison of two columns](https://community.grafana.com/t/grafana-table-conditional-cell-color-based-on-comparison-of-two-columns/160817)

<div class="topic-metadata">

**Author:** [@skmlmis](https://community.grafana.com/u/skmlmis)\
**Replies:** 2\
**Last updated:** [January 9, 2026, 12:24am UTC](https://community.grafana.com/t/grafana-table-conditional-cell-color-based-on-comparison-of-two-columns/160817 "2026-01-09T00:24:07Z")

</div>

In a Grafana Table visualization using version 12.3.1, I have two numeric columns (Column A and Column B). I want to apply conditional formatting such that: If Column A \> Column B, then Column A cell background shoul…

---

## [504 Gateway Error when connection to MSSQL Server](https://community.grafana.com/t/504-gateway-error-when-connection-to-mssql-server/159841)

<div class="topic-metadata">

**Author:** [@clsch](https://community.grafana.com/u/clsch)\
**Replies:** 9\
**Last updated:** [December 3, 2025, 10:31am UTC](https://community.grafana.com/t/504-gateway-error-when-connection-to-mssql-server/159841 "2025-12-03T10:31:16Z")

</div>

We are running Grafana Enterprise on an open shift environment. We have several MSSQL datasources which connect to differnet servers and databases. Everything is working fine, but as soon as a sql query takes longer than…

---

## [SQL Expressions fail when source table has no rows](https://community.grafana.com/t/sql-expressions-fail-when-source-table-has-no-rows/159516)

<div class="topic-metadata">

**Author:** [@mattfenner](https://community.grafana.com/u/mattfenner)\
**Replies:** 0\
**Last updated:** [November 19, 2025, 2:09am UTC](https://community.grafana.com/t/sql-expressions-fail-when-source-table-has-no-rows/159516 "2025-11-19T02:09:11Z")

</div>

I don’t know if this counts as a bug or not, but I run into this every time I try to use the new SQL Expressions I hit the same problem. They work well in the normal case but they error when the source table has no rows. …

---

## [Variable key value regex, using Grafana interpolates in dashboard](https://community.grafana.com/t/variable-key-value-regex-using-grafana-interpolates-in-dashboard/150738)

<div class="topic-metadata">

**Author:** [@bs43](https://community.grafana.com/u/bs43)\
**Replies:** 7\
**Last updated:** [September 2, 2025, 2:04pm UTC](https://community.grafana.com/t/variable-key-value-regex-using-grafana-interpolates-in-dashboard/150738 "2025-09-02T14:04:41Z")

</div>

I am trying to use the value returned by my query as key value This is the regex i used But this is only returning the first row only cutting out rest of the rows returned by the query used in the variable And i ha…

---

## [Connection Microsoft SQL Server 2022 with Grafana](https://community.grafana.com/t/connection-microsoft-sql-server-2022-with-grafana/156833)

<div class="topic-metadata">

**Author:** [@csa6](https://community.grafana.com/u/csa6)\
**Replies:** 4\
**Last updated:** [August 29, 2025, 11:25am UTC](https://community.grafana.com/t/connection-microsoft-sql-server-2022-with-grafana/156833 "2025-08-29T11:25:13Z")

</div>

I am trying to establish connection from my Microsoft SQL Server 2022 to Grafana. But the connection was not established. This is my Instance IP Setup. This is the Database This is the connection and authenticati…

---

## [How to include a column in the alert query, but not have it be used as a label for grouping instances](https://community.grafana.com/t/how-to-include-a-column-in-the-alert-query-but-not-have-it-be-used-as-a-label-for-grouping-instances/154900)

<div class="topic-metadata">

**Author:** [@nixonk23](https://community.grafana.com/u/nixonk23)\
**Replies:** 1\
**Last updated:** [July 25, 2025, 10:27pm UTC](https://community.grafana.com/t/how-to-include-a-column-in-the-alert-query-but-not-have-it-be-used-as-a-label-for-grouping-instances/154900 "2025-07-25T22:27:41Z")

</div>

What Grafana version and what operating system are you using? 9.4.3 PostgreSQL Slack Contact Point I have an alert that tracks the latest performance based on Git commits, the query result looks something like this: {…

---

## [Timeseries based on SQL data source. Tags column](https://community.grafana.com/t/timeseries-based-on-sql-data-source-tags-column/153133)

<div class="topic-metadata">

**Author:** [@sbll885](https://community.grafana.com/u/sbll885)\
**Replies:** 4\
**Last updated:** [July 13, 2025, 7:38am UTC](https://community.grafana.com/t/timeseries-based-on-sql-data-source-tags-column/153133 "2025-07-13T07:38:22Z")

</div>

Hi, I’m trying to build a SQL query for Timeseries. Basic query selects time, value, series and tags. Grafana understand time and as time, value as value and all others groups as series. Thus my legend includes series \*…

---

## [Daily value based on an only increasing value (Influxdb3)](https://community.grafana.com/t/daily-value-based-on-an-only-increasing-value-influxdb3/154050)

<div class="topic-metadata">

**Author:** [@jaal](https://community.grafana.com/u/jaal)\
**Replies:** 0\
**Last updated:** [July 7, 2025, 7:26am UTC](https://community.grafana.com/t/daily-value-based-on-an-only-increasing-value-influxdb3/154050 "2025-07-07T07:26:41Z")

</div>

Hi, I’m currently trying to create some boards for my new influx3 setup. To start with some easy stuff, I tried to create a board, which shows the daily rain value. The value in my database is only increasing and never…

---

## [Problem with auto series-mapping on XY Chart](https://community.grafana.com/t/problem-with-auto-series-mapping-on-xy-chart/152881)

<div class="topic-metadata">

**Author:** [@antonbj00](https://community.grafana.com/u/antonbj00)\
**Replies:** 0\
**Last updated:** [June 18, 2025, 10:01am UTC](https://community.grafana.com/t/problem-with-auto-series-mapping-on-xy-chart/152881 "2025-06-18T10:01:21Z")

</div>

Hello. I have a table that looks like this: | name | epoch | path | duration | ------------------------------------- | test | 1234 | a | 100 | | test | 1214 | a.b | 100 | | test | 1224 |…

---

## [Dashboard Variable - Key Value Not mapping](https://community.grafana.com/t/dashboard-variable-key-value-not-mapping/150677)

<div class="topic-metadata">

**Author:** [@bs43](https://community.grafana.com/u/bs43)\
**Replies:** 1\
**Last updated:** [June 5, 2025, 7:55am UTC](https://community.grafana.com/t/dashboard-variable-key-value-not-mapping/150677 "2025-06-05T07:55:55Z")

</div>

I am trying to map the key and value from an value return by the big query data source so, The regex used is this But instead of getting all the row value i am getting only the first row and then modified to Got…

---

## [How to display mysql select data as time serial graph](https://community.grafana.com/t/how-to-display-mysql-select-data-as-time-serial-graph/139424)

<div class="topic-metadata">

**Author:** [@sjh0207](https://community.grafana.com/u/sjh0207)\
**Replies:** 3\
**Last updated:** [May 18, 2025, 7:31am UTC](https://community.grafana.com/t/how-to-display-mysql-select-data-as-time-serial-graph/139424 "2025-05-18T07:31:35Z")

</div>

I would like to save Linux’s iftop command in DB and display it as a time series dashboard through sql query. The query is: SELECT UNIX\_TIMESTAMP(timestamp) AS time\_sec, bytes AS value, CONCAT(src\_ip, ":", src\_po…

---

## [JOIN InfluxDB V3 and MS-SQL data](https://community.grafana.com/t/join-influxdb-v3-and-ms-sql-data/150602)

<div class="topic-metadata">

**Author:** [@steph2795](https://community.grafana.com/u/steph2795)\
**Replies:** 1\
**Last updated:** [May 16, 2025, 8:47am UTC](https://community.grafana.com/t/join-influxdb-v3-and-ms-sql-data/150602 "2025-05-16T08:47:22Z")

</div>

What Grafana version and what operating system are you using? V12.0.0 What are you trying to achieve? I want to join data from an InfluxDB v3 DB with SQL query and data from MS-SQL and display multiple series with…

---

## [Error When Adding Microsoft SQL Server 2012 R2 Data Source in Grafana](https://community.grafana.com/t/error-when-adding-microsoft-sql-server-2012-r2-data-source-in-grafana/149795)

<div class="topic-metadata">

**Author:** [@mayssabensalah](https://community.grafana.com/u/mayssabensalah)\
**Replies:** 1\
**Last updated:** [May 6, 2025, 3:08pm UTC](https://community.grafana.com/t/error-when-adding-microsoft-sql-server-2012-r2-data-source-in-grafana/149795 "2025-05-06T15:08:29Z")

</div>

Hello, I am trying to add a new data source for a Microsoft SQL Server 2012 R2 instance in Grafana( version 11.5.1) To access the database, I usually connect using the following format: IP\_address\\SQL\_instance\_name. I…

---

## [Aggregate every minute data to daily(summed) data](https://community.grafana.com/t/aggregate-every-minute-data-to-daily-summed-data/148187)

<div class="topic-metadata">

**Author:** [@snowpg](https://community.grafana.com/u/snowpg)\
**Replies:** 3\
**Last updated:** [April 21, 2025, 3:10pm UTC](https://community.grafana.com/t/aggregate-every-minute-data-to-daily-summed-data/148187 "2025-04-21T15:10:05Z")

</div>

What Grafana version and what operating system are you using? Grafana v10.3.1 (00a22ff8b2) - Windows 11 What are you trying to achieve? I have a database (In MySQL) having data like this: \*|Name | TS | Value| |— | …

---

## [Handling selection from 10k+ parameters](https://community.grafana.com/t/handling-selection-from-10k-parameters/145271)

<div class="topic-metadata">

**Author:** [@stijnilsen](https://community.grafana.com/u/stijnilsen)\
**Replies:** 10\
**Last updated:** [March 2, 2025, 9:26pm UTC](https://community.grafana.com/t/handling-selection-from-10k-parameters/145271 "2025-03-02T21:26:41Z")

</div>

Hi, We are testing satellites and the telemetry (during testing on ground) is injected into a mysql database. I have 10k+ different parameters in this database. The user (test engineer) wants to be able to select speci…

---

## [Removing first & last data points](https://community.grafana.com/t/removing-first-last-data-points/120694)

<div class="topic-metadata">

**Author:** [@RocketSurgeon](https://community.grafana.com/u/RocketSurgeon)\
**Replies:** 5\
**Last updated:** [February 17, 2025, 11:03am UTC](https://community.grafana.com/t/removing-first-last-data-points/120694 "2025-02-17T11:03:48Z")

</div>

Is there any way to clip the first and / or last data points from a time series / table? I’m querying data from InfluxDB via FlightSQL / Arrow SQL and aggregating period host stats by clusters of hosts. As each host is …

---

## [Discrepancy when pulling column of 'date' type from PostgreSQL](https://community.grafana.com/t/discrepancy-when-pulling-column-of-date-type-from-postgresql/135773)

<div class="topic-metadata">

**Author:** [@unclegasya](https://community.grafana.com/u/unclegasya)\
**Replies:** 6\
**Last updated:** [November 7, 2024, 3:23pm UTC](https://community.grafana.com/t/discrepancy-when-pulling-column-of-date-type-from-postgresql/135773 "2024-11-07T15:23:23Z")

</div>

Grafana v11.2.2 (c47b921ef4) I need to pull several rows from Postgres db. One of the columns is of ‘date’ type. I made the query short in attempt to troubleshoot. SELECT DISTINCT batch\_dt FROM nodes ORDER BY 1 …

---

## [Distinguish table query with a custom "legend" name](https://community.grafana.com/t/distinguish-table-query-with-a-custom-legend-name/135702)

<div class="topic-metadata">

**Author:** [@breeze7086](https://community.grafana.com/u/breeze7086)\
**Replies:** 2\
**Last updated:** [November 5, 2024, 9:44am UTC](https://community.grafana.com/t/distinguish-table-query-with-a-custom-legend-name/135702 "2024-11-05T09:44:25Z")

</div>

Hi, I have a table panel with multiple SQL queries. As you see, I can select different query in the drop-down menu. My question is how can I use a custom “name” to distinguish different queries? I tried with overr…

---

## [Postgres lock using linux and xk6-sql](https://community.grafana.com/t/postgres-lock-using-linux-and-xk6-sql/135636)

<div class="topic-metadata">

**Author:** [@bohdanpervii](https://community.grafana.com/u/bohdanpervii)\
**Replies:** 0\
**Last updated:** [November 4, 2024, 1:40pm UTC](https://community.grafana.com/t/postgres-lock-using-linux-and-xk6-sql/135636 "2024-11-04T13:40:53Z")

</div>

I got a Postgres db in docker, API service in docker, local xk6-sql and linux xk6-sql build in azure pipelines Locally (xk6 on windows laptop and docker desktop) all requests and db queries work fine in any order, but wh…

---

## [Chart Sorting in SQL](https://community.grafana.com/t/chart-sorting-in-sql/134569)

<div class="topic-metadata">

**Author:** [@xiurzeph](https://community.grafana.com/u/xiurzeph)\
**Replies:** 5\
**Last updated:** [October 18, 2024, 7:54pm UTC](https://community.grafana.com/t/chart-sorting-in-sql/134569 "2024-10-18T19:54:46Z")

</div>

In this code, how can I sort this correctly, if I remove month name, it sorts correctly, but I want this visible. Thanks! SELECT DISTINCT Month(HPD:Help Desk.Submit Date) +‘-’+datename(‘mm’,HPD:Help Desk.Submit Date)…

---

## [$\_\_timeFilter(DateTime) in a EXEC(@sql)](https://community.grafana.com/t/timefilter-datetime-in-a-exec-sql/131897)

<div class="topic-metadata">

**Author:** [@radie](https://community.grafana.com/u/radie)\
**Replies:** 2\
**Last updated:** [October 10, 2024, 12:05pm UTC](https://community.grafana.com/t/timefilter-datetime-in-a-exec-sql/131897 "2024-10-10T12:05:16Z")

</div>

Our SQL server contains around 160 MS SQL databases, one for each premises and a central BI database. My dashboard uses variables to extract data from the relevant databases, but the database names must be dynamically bu…

---

## [Wrong timefilter](https://community.grafana.com/t/wrong-timefilter/133587)

<div class="topic-metadata">

**Author:** [@jasperclauwaert](https://community.grafana.com/u/jasperclauwaert)\
**Replies:** 3\
**Last updated:** [October 7, 2024, 8:26am UTC](https://community.grafana.com/t/wrong-timefilter/133587 "2024-10-07T08:26:31Z")

</div>

Hello, I’m having troubles filtering my data with the timepicker (SQL server). When I try to filter the data by an absolute timerange, it gets filtered like it should. But when I try to filter the data by a relativ…

---

## [Virtual Cycle number creation](https://community.grafana.com/t/virtual-cycle-number-creation/133228)

<div class="topic-metadata">

**Author:** [@fjanni](https://community.grafana.com/u/fjanni)\
**Replies:** 2\
**Last updated:** [October 4, 2024, 5:31pm UTC](https://community.grafana.com/t/virtual-cycle-number-creation/133228 "2024-10-04T17:31:43Z")

</div>

Hi, I’d need your help how to create a virtual Cycle\_ID in an SQL table. It is necessary to calculate the total consumption of a certain cycle. I have a database, fields are ID, Timestamp, Countervalue. Countervalue sho…

---

## [Alerts on multi-frame time series error](https://community.grafana.com/t/alerts-on-multi-frame-time-series-error/126271)

<div class="topic-metadata">

**Author:** [@federicos1](https://community.grafana.com/u/federicos1)\
**Replies:** 6\
**Last updated:** [September 27, 2024, 5:30pm UTC](https://community.grafana.com/t/alerts-on-multi-frame-time-series-error/126271 "2024-09-27T17:30:17Z")

</div>

Grafana version: v9.5.1 Hi! I am working with a panel that contains multi-frame time series, and I am trying to generate an alert based on this. The query accesses MSSQL and retrieves: value label time In the panel,…

---

## [Dynamic Dashboard Variables in Grafana v11.1.0 Based on User Teams](https://community.grafana.com/t/dynamic-dashboard-variables-in-grafana-v11-1-0-based-on-user-teams/132580)

<div class="topic-metadata">

**Author:** [@sonian](https://community.grafana.com/u/sonian)\
**Replies:** 6\
**Last updated:** [September 26, 2024, 8:48am UTC](https://community.grafana.com/t/dynamic-dashboard-variables-in-grafana-v11-1-0-based-on-user-teams/132580 "2024-09-26T08:48:49Z")

</div>

Hello everyone, I’m currently working with Grafana v11.1.0 and SQL Server and I have a dashboard that needs to display variables that vary based on the team of the connected user. I have three teams, each with its own …

---

## [Db query error: mssql: Incorrect syntax near the keyword 'AS'](https://community.grafana.com/t/db-query-error-mssql-incorrect-syntax-near-the-keyword-as/129506)

<div class="topic-metadata">

**Author:** [@monitorhalk](https://community.grafana.com/u/monitorhalk)\
**Replies:** 4\
**Last updated:** [August 26, 2024, 1:47pm UTC](https://community.grafana.com/t/db-query-error-mssql-incorrect-syntax-near-the-keyword-as/129506 "2024-08-26T13:47:33Z")

</div>

Hello Everyone, SELECT DK\_KOD, $\_\_time(DATEADD(HOUR, -3, MQ\_TAR\_ZMN)), SUM(ADET) AS toplam FROM \[MYDB\].\[dbo\].\[Sayi\] WHERE DK\_KOD = ‘XYZ’ AND (TXN\_KOD = ‘A’ OR TXN\_KOD = ‘B’ OR TXN\_KOD = ‘C’ OR TXN\_KOD = ‘D’ OR T…

[Next page](https://community.grafana.com/tag/sql/284.md?match_all_tags=true&page=1&tags%5B%5D=sql)
