trick problem

Поиск
Список
Период
Сортировка
От 纪晓曦
Тема trick problem
Дата
Msg-id 37a11ce00909031802g52397a3atbc55d7d6b8e2cf13@mail.gmail.com
обсуждение исходный текст
Список pgsql-general
Consider the following relational schema about daily stock prices.
StockPrice (stockid; timeid; price)
We make the simplifying assumption that timeid is an integer that count the number
of days from a particular date in the past (that is, the stock prices on the x-th day can
be found by a simple selection condition of WHERE timeid = x).
Write the following queries in SQL.
Print out the 15-day moving averages of each stock sorted by stockid and timeid
(ascending order).
If the stock prices for a particular stock are
timeid price
5 10
6 12
7 14
then its 2-day moving averages will be
timeid 2-day moving average
6 11.0000000000000000
7 13.0000000000000000
Note that we want strict 15-day moving average, meaning that
1. There should be no 15-day moving average for the first 14 days (as shown in
the above example).
2.If there are missing data (e.g., the price for a stock at some date is missing)
within the 15-day (sliding) window, the computation on this window should
be abandoned.

I don't know how to do it without plsql

В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: pg_ctl with unix domain socket?
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: How do I store tables on a remote host?