sql query issue
Posted by: Suleman Butt
Date: October 12, 2012 08:54AM

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.

Options: ReplyQuote


Subject
Written By
Posted
sql query issue
October 12, 2012 08:54AM
October 12, 2012 10:39AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.