php - calculate two consecutive days with XYZ values within a week in a month -


i have database in mysql , have table named user_daily_data_recorded. have following columns

  1. date_of_record
  2. steps_walked
  3. member_id

the table contains data of each , every date , populated regularly. want send congratulation mail user/members who have walked 15000 steps @ least 2 days per week on month (say in month february user1 has walked 15000 on monday , thursday receive congratulatory mail). should do? let me know if question not clear. file containing script executed once per month. need find 2 days 15000 steps per week in a particular month.

if want know how select users should e-mail today, help:

select member_id   user_daily_data_recorded uddr        # selects users created record today.        join (select distinct ( member_id ) id                user_daily_data_recorded               date_of_record = curdate()) todays_users          on todays_users.id = uddr.id        # selects users below 15000 steps yesterday.        join (select distinct ( member_id ) id                user_daily_data_recorded               sum(steps_walked) < 15000                     , date_of_record < curdate()              group  member_id) yesterday_below_mark_users          on yesterday_below_mark_users.id = uddr.id # selects members on 15000 steps today.  sum(uddr.steps_walked) >= 15000 group  member_id   

i didn't tested it, may steps :)

edit: steps on mark week:

select distinct( member_id )   user_daily_data_recorded uddr        join (select member_id             id,                     count(date_of_record) dates_over_mark                user_daily_data_recorded               month(date_of_record) = month(curdate())                     , steps_walked >= 15000              group  week(date_of_record)              having dates_over_mark >= 2) very_active_members          on very_active_members.id = uddr.members_id   

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -