Nested Query

Hi,

I want to create query for following use case:

DB is as follow:

CountryName || CityName || Edits || deleted || TimeStamp

United States || New York || 121 || true || 2015-09-12T22:16:04.354Z

India || Mumbai || 70 || true || 2016-09-12T22:02:05.807Z

United States || New York || 65 || false || 2016-10-12T22:00:29.941Z

India || Delhi || 98 || false || 2017-09-12T22:16:04.354Z

India || Mumbai || 345 || false || 2017-12-12T20:45:18.269Z

United States || New York || 98 || true || 2018-09-12T22:02:05.807Z

QUERY: I want to find total count of deleted records in the past 2 edits GroupBy CountryName

Expected Results:

United States => { “count” : 1}

India => { “count” : 0}

How to write a DRUID Query for it?

Thank you,

Niraj Dedhia

Niraj,

You can see the guidelines here in creating Druid queries http://druid.io/docs/latest/querying/querying & http://druid.io/docs/latest/querying/sql.html . You can use either TopN or GroupBy for your use case.

Rommel Garcia

Hi Rommel,

Thank you for your response and providing me the link.

My use case looks like combination of GroupBy and TopN query and not just one single query.

It says, For every country (GroupBy) I want to get top 2 edits (Top N) records and then apply filter on it.

Actually I wanted to know how the query would like for the above case.

Thank you,

Niraj Dedhia