Top list of count grouped by tag in grafana

I currently display all idocs with the next query

SELECT count(entry_status) FROM idoc_entry WHERE $timeFilter and entry_status=‘ERROR IN HYBRIS’ GROUP BY idoc_number, time($__interval)

this shows the amount of time each idoc had an ‘error in hybris’ entry_status. But i want to change it it to only display the top 10 idocs with the most error in hybris counts.

I tried this in my influx db

SELECT idoc_number, TOP(test,5) FROM (SELECT count(entry_status) as test FROM idoc_entry where entry_status = ‘ERROR IN HYBRIS’ GROUP BY idoc_number)
name: idoc_entry
time idoc_number top


0 0000000979532169 24
0 0000000979532169 24
0 0000000979532169 24
0 0000000979532169 24
0 0000000979532169 24

I tried using this in grafana with the timefilters added but its not working, query used:

SELECT idoc_number, TOP(test,10) FROM (
SELECT count(entry_status) as test FROM idoc_entry WHERE $timeFilter and entry_status=‘ERROR IN HYBRIS’ GROUP BY idoc_number, time($__interval))

This is the result Screenshot - c1663f62136d57c902c764a57f11ace9 - Gyazo

Could anyone help me out with this one?