MySQL: Extract data for line graph to show counts over time period -


i have table captures when events (say alien attacks) happened. each time aliens attack new record created in table (some days can have multiple attacks , days none)..

   attack_id         attack_date    ---------         ---------    1                 03/12/2015    2                 03/12/2015    3                 04/01/2015    4                 04/21/2015    5                 06/14/2015 

i want show in line graph how many attacks occured per week. x-axis weeks in year , y-axis number attacks in week.

thus result set feed graph might like

week            number of attacks ----            ----------------- 

can suggest mysql query?

two things need: week() function week date, , count() how many attacks happened:

select week(alien_date) attack_week, count(*) num_of_attacks   yourtable  group week(alien_date) 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -