mysql - Query for all values that appear every day -
i've got logs table dates attached log items themselves. log tracks impressions advertisement spaces used publishers display ads. looks (greatly simplified) this:
id | date | adspace_id | impressions
when adspace has no impressions day, deliver 0. other times, it's not logged. other times, adspace_id logged several times o same date. (i not know why.) i'm trying pull adspace_ids have value every day on 30 day period, can't figure out how this. i've tried
select adspace_id logstbl (`date` > "2014-02-01" , `date` < "2014-03-02") , impressions != 0
but pulls space log between dates rather space logs on all of them.
i think i'm missing something, , help appreciated.
you count how many days there between dates (for example, 30 days) , id's many dates assigned them (this sql can refactored, idea):
select adspace_id ( select adspace_id, count(date) cnt ( select distinct adspace_id, date logstbl (`date` > "2014-02-01" , `date` < "2014-03-02") , impressions != 0 ) grouping adspace_id ) b b.cnt > 30
mysql
No comments:
Post a Comment