Hi all,
I am finding it difficult to build one mysql query.
I have a table messages_stats_analysis_ota, with 4 columns: [brand_code, date_time_from, date_time_to, success_count].
I want the value inside 'success_count' against individual 'brand_code', which lie within the last 7 days from the current date.
u2, 01.10.2012, 07.10.2012, 100
u2, 02.10.2012, 08.10.2012, 100
u2, 03.10.2012, 07.10.2012, 100
u2, 08.10.2012, 14.10.2012, 50
fr, 01.10.2012, 07.10.2012, 200
Now lets assume, the current date is 08.10.2012.
I want only the follwoing 2 rows to be retrieved:
u2, 01.10.2012, 07.10.2012, 100
fr, 01.10.2012, 07.10.2012, 200
I tried to build this query:
SELECT * FROM messages_stats_analysis_ota WHERE date_time_from >= DATE_SUB(CURDATE(), INTERVAL 7 DAY);
but it gives me, the follwoing, which i dont want:
u2, 01.10.2012, 07.10.2012, 100
u2, 02.10.2012, 08.10.2012, 100
u2, 03.10.2012, 07.10.2012, 100
fr, 01.10.2012, 07.10.2012, 200
Assumtpion is current date is: 08.10.2012.
Coudl someone please help me out?
Thanks.
I am finding it difficult to build one mysql query.
I have a table messages_stats_analysis_ota, with 4 columns: [brand_code, date_time_from, date_time_to, success_count].
I want the value inside 'success_count' against individual 'brand_code', which lie within the last 7 days from the current date.
u2, 01.10.2012, 07.10.2012, 100
u2, 02.10.2012, 08.10.2012, 100
u2, 03.10.2012, 07.10.2012, 100
u2, 08.10.2012, 14.10.2012, 50
fr, 01.10.2012, 07.10.2012, 200
Now lets assume, the current date is 08.10.2012.
I want only the follwoing 2 rows to be retrieved:
u2, 01.10.2012, 07.10.2012, 100
fr, 01.10.2012, 07.10.2012, 200
I tried to build this query:
SELECT * FROM messages_stats_analysis_ota WHERE date_time_from >= DATE_SUB(CURDATE(), INTERVAL 7 DAY);
but it gives me, the follwoing, which i dont want:
u2, 01.10.2012, 07.10.2012, 100
u2, 02.10.2012, 08.10.2012, 100
u2, 03.10.2012, 07.10.2012, 100
fr, 01.10.2012, 07.10.2012, 200
Assumtpion is current date is: 08.10.2012.
Coudl someone please help me out?
Thanks.