Mysql Avg function for recent 15 records by date (order date desc) in every symbol
- by venkatesh
i am trying to create a statement in sql (for a table which holds stock symbols and price on specified date) with avg of 5 day price and avg of 15 days price for each symbol.
table description:
symbol
open
high
close
date
the average price is calculated from last 5 days and last 15 days. i tried this for getting 1 symbol:
SELECT avg(close),
avg(`trd_qty`)
FROM (select *
from cashmarket
WHERE symbol = \'hdil\'
order by `M_day` desc
limit 0,15 ) s
...but I couldn't get the desired the list for showing avg values for all symbols.