我使用了变量选择器,然后一个变量有多条数据。如果一个一个编写的话需要有两百多条Queries。
我现在寻求一个更方便的sql编写。我找到了一个可能的结果,但是还是出现一些问题,无法达到我想要的效果。
SELECT
time,
CONCAT(Instruments, ’ - ', Exchange) AS symbol,
price_spot AS price
FROM grafana_business.gra_cexarbi_binance_basisarbi_dashtest03_5m_coin
WHERE
Exchange IN (${Exchange})
AND Type IN (${Type})
AND Instruments IN (${Instruments})emphasized text
这是现在的sql语句,当我单选的时候,都可以顺利的展现出来,当我多选Instruments时,并不能展现出多条折线图,而是一段纵横交错的折线。
我现在的需求是,如何设置更改,当我多选Instruments时会出现多条折线
Hi,
I guess you’ll have much more luck here by using English Can you edit your post?
I used a variable selector, and then a variable has multiple data. If I write them one by one, I need more than 200 queries.
I am now looking for a more convenient sql writing. I found a possible result, but there are still some problems and I can’t achieve the effect I want.
This is the current SQL statement. When I select a single one, it can be displayed smoothly. When I select multiple Instruments, it cannot display multiple line graphs, but a criss-cross line graph.
My current requirement is how to set the change so that multiple line graphs will appear when I select multiple Instruments
Google translate
Try
Where column in (‘${variable:csv}’)
使用谷歌翻译以英文发布
我通过改变JSON,然后实现了这一功能,只需要两个Queries就可以实现之前上百个的效果。但是现在我并不清楚如果不改变json如何实现这一效果
I implemented this function by changing the JSON. Only two Queries are needed to achieve the effect of hundreds before. But now I don’t know how to achieve this effect without changing json
Did you try the query that was recommended
Where column in (‘${variable:csv}’)
我不知道这个应该如何去使用,你能发给我对应的链接,或者有什么用例我可以学习一下的吗
I don’t know how to use this. Can you send me the corresponding link, or is there any use case I can learn from?
thank you very much!
Sorry it should be
servers = [‘test1’, ‘test2’]
String to interpolate: ‘${servers:singlequote}’
Interpolation result: “‘test1’,‘test2’”
SELECT
time AS time,
Instruments AS metric,
price_spot AS value
FROM
grafana_business.gra_cexarbi_binance_basisarbi_dashtest03_5m_coin
WHERE
$__timeFilter(time)
AND Exchange IN (${Exchange})
AND Type IN (${Type})
AND Instruments IN (${Instruments})
ORDER BY
time ASC;
==============
上面是我通过chatGPT修改的。下面是我原来要写上百个Queries的sql。但是我还是不会使用你给我讲的方法修改
The above is what I modified through chatGPT. Below is the sql that I originally wanted to write hundreds of Queries. But I still don’t know how to modify it using the method you told me.
SELECT time, symbol, price_spot as ADAUSD_Price_Binance
FROM grafana_business.gra_cexarbi_binance_basisarbi_dashtest03_5m_coin
WHERE Exchange in ($Exchange)
AND Type in ($Type)
AND Instruments IN ($Instruments)
AND (
(Exchange = ‘binance’ AND Type = ‘delivery with coin margin’ AND Instruments = ‘ADAUSD (binance-delivery)’ )
)