Subject | How to get average price from last 10 buyings |
---|---|
Author | Fabio Cardoso |
Post date | 2009-08-25T22:36:33Z |
Gentleman, I use Firebird 2.1,
I have two tables, BUYINGS and PRODUCTS
PRODUCTS
produ_averageprice numeric (15.1)
BUYINGS
buying_price numeric (15.1)
Well, I have bought one product 15 times, each cost price is different. So, I want field produ_averageprice get the average of the last 10 cost prices recorded in buying_price.
How do I make a select statement for this?
I think it's something like "select avg(select last 10 buying_price from BUYINGS)"
Were I clear? Please tell me if no, ok?
Thanks from Brazil,
Fabio.
[Non-text portions of this message have been removed]
I have two tables, BUYINGS and PRODUCTS
PRODUCTS
produ_averageprice numeric (15.1)
BUYINGS
buying_price numeric (15.1)
Well, I have bought one product 15 times, each cost price is different. So, I want field produ_averageprice get the average of the last 10 cost prices recorded in buying_price.
How do I make a select statement for this?
I think it's something like "select avg(select last 10 buying_price from BUYINGS)"
Were I clear? Please tell me if no, ok?
Thanks from Brazil,
Fabio.
[Non-text portions of this message have been removed]