Generating report with MySQL and Rails - how?

Posted by Arywista on Stack Overflow See other posts from Stack Overflow or by Arywista
Published on 2009-12-09T19:22:28Z Indexed on 2010/03/18 15:01 UTC
Read the original article Hit count: 227

Filed under:
|

Here is my data model from my application:

id :integer(4) not null, primary key spam :boolean(1) not null duplicate :boolean(1) not null ignore :boolean(1) not null brand_id :integer(4) not null attitude :string not null posted_at :datetime not null

Attitude could have 3 states: negative, positive, neutral.

I want to generate resultset in table, this way, for each day between start and end date:

date       | total | positive | neutral | negative
2009-10-10 |   12  |     4    |    7    |     1
(...)
2009-10-30 |   5   |     2    |    1    |     1

And ignore all records which have:

duplicate = true ignore = true spam = true

How it's could be done?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about ruby-on-rails