Hi,
I am trying to write a routine to calculate an average based on the 5
entries before a certain entry in a table based on the _date column.
Is this possible with a select statement? The limit keyword has an offset
and a limit but can you tell select to return the 5 entries before a
certain entry.
Example:
create table chart(
_date date,
symbol varchar(10),
close double(22,3),
5avg double(22,3);
5avg should be the last 5 closing values for a symbol. Any ideas on how
to do this most efficiently with MySQL would be greatly appreciated.
Please cc me on replies.
Thanks in advance,
Shane
--
Shane Wegner: shane@stripped
Sysadmin, Continuum Systems: http://www.cm.nu Tel: (604) 930-0530
Personal website: http://www.cm.nu/~shane Fax: (604) 930-0529
PGP: keyid: 2048/F5C2BD91 ICQ UIN: 120000
Fingerprint: 8C 48 B9 D8 53 BB D8 EF
76 BB DB A2 1C 0D 1D 87
Attachment: [application/pgp-signature]