code_junkie

MySQL autogenerate statistics fram data

Nov 13th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.20 KB | None | 0 0
  1. SELECT
  2. YEAR(my_date) as my_year,
  3. MONTH(my_date) as my_month,
  4. sum(Distance) / sum(TimeForDistance) AS velocity
  5. FROM your_table
  6. GROUP BY my_year, my_month
  7. ORDER BY my_year, my_month
Add Comment
Please, Sign In to add comment