Hi.
I have a table containing:
id, date, open, close, high, low, volumen, share_id
The table is used for daily stock information. I want to make a query that
count rows where open, close, high,low, volumen, share_id are the same for
the last 2 days that are in the date field.
example:
id | date | open| close | high | low | volumen | share_id
1 | 2005-03-22 | 61.5 | 61 | 61.5 | 61 | 12369 | 1
283 | 2005-03-23 | 61 | 61 | 61.5 | 61 | 29141 | 1
565 | 2005-03-24 | 61 | 61 | 61.5 | 61 | 29141 | 1
In this case i want a count so i know that there are 1 (or more) rows that
are identical with the day before.
This will be used to determine if the last day was a nonstockday. If 99% of
the rows with the highest date is identical with the secound highest date it
is properly a nonstockday.
I run mysql 4.0.23 so i cant use the subquery. I really dont have any idea
how to solve this. I cant even get a query to return the secound highest
date to work. I tried:
SELECT max(date) from daily_rate_of_e xchange_1
where date <= DATE_ADD(max(da te),interval -1 day);
but get : Invalid use of group function.
If i insert a date instead of the max(date) in the DATE_ADD function it
works. But i need it to be dynamic.
As you can tell im new to mysql queries, but would be thankfull if someone
would post an idea, or point in a direction where the anwser might be.
Thanks
-D Kjærgaard
I have a table containing:
id, date, open, close, high, low, volumen, share_id
The table is used for daily stock information. I want to make a query that
count rows where open, close, high,low, volumen, share_id are the same for
the last 2 days that are in the date field.
example:
id | date | open| close | high | low | volumen | share_id
1 | 2005-03-22 | 61.5 | 61 | 61.5 | 61 | 12369 | 1
283 | 2005-03-23 | 61 | 61 | 61.5 | 61 | 29141 | 1
565 | 2005-03-24 | 61 | 61 | 61.5 | 61 | 29141 | 1
In this case i want a count so i know that there are 1 (or more) rows that
are identical with the day before.
This will be used to determine if the last day was a nonstockday. If 99% of
the rows with the highest date is identical with the secound highest date it
is properly a nonstockday.
I run mysql 4.0.23 so i cant use the subquery. I really dont have any idea
how to solve this. I cant even get a query to return the secound highest
date to work. I tried:
SELECT max(date) from daily_rate_of_e xchange_1
where date <= DATE_ADD(max(da te),interval -1 day);
but get : Invalid use of group function.
If i insert a date instead of the max(date) in the DATE_ADD function it
works. But i need it to be dynamic.
As you can tell im new to mysql queries, but would be thankfull if someone
would post an idea, or point in a direction where the anwser might be.
Thanks
-D Kjærgaard
Comment