How to perform a SELECT in the results returned from a GROUP BY Druid?

后端 未结 1 436
情话喂你
情话喂你 2021-01-20 15:51

I am having a hard time converting this simple SQL Query below into Druid:

SELECT country, city, Count(*) 
FROM people_data 
WHERE name=\"Mary\" 
GROUP BY co         


        
相关标签:
1条回答
  • 2021-01-20 16:40

    Simple answer is that you cannot select arbitrary dimensions in your groupBy queries.

    Strictly speaking even SQL query does not make sense. If for a given combination of country, city there are many different values of name and street, then how do you squeeze that into a single row? You have to aggregate them, e.g. by using max function.

    In this case you can include the same column in your data as both dimension and metric, e.g. name_dim and name_metric, and include corresponding aggregation over your metric, max(name_metric).

    Please note, that if these columns, name etc, have high granularity values, then that will kill Druid's roll-up feature.

    0 讨论(0)
提交回复
热议问题