PDA

View Full Version : Can MYSQL do this alone ?


nabil
08-08-2002, 05:35 AM
Several DBA's told me that it can be done but none is able to provide me with a query yet ...Any thoughts on that:

select from a table column1 only if column2 >1 and occured on 3 day consecutively based on date column execluding the whole record if column2 may also have vaules <=1 in same date...

for example

date column1 column2
2002-08-03 test 5
2002-08-03 test 6
2002-08-03 test 1
2002-08-03 test1 2
2002-08-03 test1 2
2002-08-03 test2 5

2002-08-04 test 0
2002-08-04 test1 5
2002-08-04 test1 9
2002-08-04 test2 3

2002-08-05 test 7
2002-08-05 test 5
2002-08-05 test1 0
2002-08-05 test2 3

In this case the query should retun only 1 records:

2002-08-05 test2 3



I really do appreciate any help at all...

Thanks
Nabil

Bradmont
08-08-2002, 12:49 PM
something like:
select * from <table> where column2 > column1 and date >= 'first of the 3 days' and date <= 'last of the three days'

but in your example, I don't understand how you're compairing a string to an integer... you probably won't get any meaningful results if you do that.

nabil
08-08-2002, 06:46 PM
Thanks for the reply but it did not do it..

It did not eliminate any records that had duplicate vaules of column2 <=1 in these 3 days in a row also it was not checking for event happening 3 days "in a row" ..

The part about compairing column2 with column1 is not there .. I am not compairning these records ????