I encountered the same problem after upgrading to Grafana 8.0 with an MS SQLServer datasource.
Changing “Format as” from “Time series” to “Table” fixed it for me. (the field is right beneath the query window)
SELECT
timestamp AS “time”,
metric_name AS metric,
metric_value
FROM table_name
ORDER BY timestamp
The Bar Gauge view is now always sorting the metrics alphabetically. As already mentioned this doesn’t change if I am additionally trying to sort in the select statement or the input database is already sorted.
Using the “Sort By” transformation doesn’t work in this case since there is no field I can select to sort by.
Switching from “Time Series” to “Table” results in an input which cannot be used by Grafana and I am not aware how I could change my Select statement such that the output is in the needed format.