I am sending city-name, company-name to esper.
These queries will count occurrences of name company pair in 5 seconds:
create context FiveSecondsContext start @now end after 5 seconds;
context FiveSecondsContext
insert into AggregatedEvent1
select count(*) as count, company, name from eBay group by name, company output snapshot when terminated;
below query should give a max-count for each city at the end of FiveSecondsContext. It seems right with my knowledge in SQL, but it doesnt give me max, it returns all the rows in AggregatedEvent1.
insert into AggrEvent2
select max(count) as value, company, name from AggregatedEvent1 group by name;
Since above is going wrong, my query below
select count(*) as cnt, company from AggrEvent2 group by company;
which tries to count the city names where a company (say: "yahoo") has a max count also goes wrong and gives me count of all the occurrences of the company name in the initial query input.
- Either issue is with groupby clause , or
- I need to figure the order in which the queries will run. Since I only have the context defined for AggregatedEvent1.