In this code, how can I sort this correctly, if I remove month name, it sorts correctly, but I want this visible. Thanks!
SELECT DISTINCT
Month(HPD:Help Desk.Submit Date) +‘-’+datename(‘mm’,HPD:Help Desk.Submit Date) AS MonthYear
[…]
Group By
MonthYear
Order by Month(`HPD:Help Desk` .`Submit Date` )
Thaks, but doing this just causes an error: 895: Sort Item must exist in Selection list if distinct is specified.
I can sort by Month(HPD:Help Desk .Submit Date ) +‘-’+datename(‘mm’,HPD:Help Desk .Submit Date ), but that causes the same sorting issue.
please post the full query with the aggregation function
basically your issue is not grafana issue. Can you do this?
select * from (
SELECT DISTINCT
Month(HPD:Help Desk.Submit Date)
+’ - '+
datename(‘mm’,HPD:Help Desk.Submit Date) AS MonthYear
,
----
Group By
MonthYear
) a
--here just capture the numeric month
order by cast(substring(MonthYear, 0,??) as int)
not sure if you are on mysql or mssql?