0

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.

  1. Either issue is with groupby clause , or
  2. I need to figure the order in which the queries will run. Since I only have the context defined for AggregatedEvent1.
change
  • 3,400
  • 7
  • 32
  • 42

1 Answers1

0

It depends on what is in the select and what is in the group, same as in a relational db. You can read up on that in here: http://esper.codehaus.org/esper-5.0.0/doc/reference/en-US/html_single/index.html#processingmodel_aggregation_output Removing "company" from the select or adding company to group would seem to do it.

user650839
  • 2,594
  • 1
  • 13
  • 9