ivbtar
ivbtar

Reputation: 879

Trimming column values while selecting with InfluxQL in Grafana Dashboard

I have a table like below. Col1 values has parenthesis like val1(12). But when I write a InfluxQL query I want to remove parenthesis and just get remaining. When the InfluxQL query runs in the output Val1(12) will be Val1

mytable:

Col1 Col2 Col3 Col4
val1(12) 332 0 1
val2(4234) 222 0 1
val3(221) 111 0 1

If i write select * from mytable it wil give as below :

Col1 Col2 Col3 Col4
val1(12) 332 0 1
val2(4234) 222 0 1
val3(221) 111 0 1

But i want the paranthesis to be removed after i run the sql like below :

Col1 Col2 Col3 Col4
val1 332 0 1
val2 222 0 1
val3 111 0 1

I couldnt find a solution for this. Should i use trim or wildcard or regex to do this? InfluxDB shell version is 1.7.6. We will run this influxql in grafana dashboard.

Upvotes: 1

Views: 844

Answers (1)

L.Newell
L.Newell

Reputation: 112

I think you'll want to make use of SUBSTRING.

e.g.

SELECT SUBSTRING(Col1,0 CHARINDEX('(',Col1)), Col2, Col3
FROM MyTable

Upvotes: 1

Related Questions