How to import SQL queries to Grafana?

Hello Guys,

I prepared some sql queries but i’m really struggling while converting to grafana mssql query.
There is not counterpart in grafana for some sql functions or i can’t find it in official doc pages. Please tell me how can i convert all of sql flexibility to grafana :slight_smile:

For instance query:
select DATEADD(MINUTE , -5, GetDate()) as DATE,
WHEN ChannelID=1 THEN ‘X1’
WHEN ChannelID=2 THEN ‘X2’
WHEN ChannelID=11 THEN ‘X3’
END as Channel,
count(*) as count
from [LOGTABLE] with (nolock) where (TransactionName =‘T1’ or TransactionName=‘T2’)
and [Date] > DATEADD(MINUTE , -5, GetDate())
group by ChannelID

By the way I’m new on Grafana.
Thanks in advance.

Please refer to documentation. You must name your time column time for starters. Everything required you should find in documentation.

Thanks for the answer! I fixed it according to doc.

Sorry about waste your time.