I have a table that has date and id column. How can I select id's of 7 days interval?
My data is:
date id
2013-07-01 11
2013-07-02 22
2013-07-03 33
2013-07-04 33
2013-07-05 44
2013-07-06 44
2013-07-07 45
2013-07-08 46
2013-07-09 47
2013-07-10 48
2013-07-11 48
2013-07-12 49
2013-07-13 50
2013-07-14 51
2013-07-15 52
2013-07-16 52
2013-07-17 53
2013-07-18 53
2013-07-19 54
What I want is:
date id
2013-07-01 11
2013-07-08 46
2013-07-15 52
Thanks
SELECT date,id FROM table1 GROUP BY WEEK(`date`, 1)
http://sqlfiddle.com/#!2/b128c/1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With