How to convert sql query


How to convert below sql to Druid query api ?

select cnt, count(distinct session_id)



select session_id, count(*) as cnt

from source

group by session_id


group by cnt;

I think that query should work as-is with Druid SQL: It would end up getting executed as a nested groupBy: