Hi, I’m getting crazy with a very basic query.
I’m connected to a SQL Server database and I would like to display the count of the selected rows in a Singlestat panel.
Unfortunately, among the option in the Value->Show configuration dropdown I do not find any ‘Count’ or similar option.
I treid to include the COUNT funziont in the SELECT statement like here:
SELECT $__timeEpoch([EndTime]), [Operation] as metric, COUNT([ExLenght (m)]) as value FROM table_sample WHERE $__timeFilter([EndTime]) AND Status = 'Completed' AND [Operation] = 'INTERMEDIATE'
but Grafana gives me this error:
mssql: Column ‘table_sample.EndTime’ is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Note that if I remove the COUNT and change the line to [ExLenght (m)]) as value the query works but obviously I do not get the Count of the values.
What I am doing wrong? Thanks for helping!