a*z 发帖数: 294 | 1 How to query stock price table (price in double) and return the the top 10%
of the highest percent return?
Thanks. |
e********g 发帖数: 2524 | 2 俺菜鸟,不是可以Desc 排序吗?
%
【在 a*z 的大作中提到】 : How to query stock price table (price in double) and return the the top 10% : of the highest percent return? : Thanks.
|
a*z 发帖数: 294 | 3 percent return needs to be calc'ed, but not allowed to write function. |
e********g 发帖数: 2524 | 4 你调用sql的程序不能算吗?还是说数据库一般都不这么用的?
俺是外行
【在 a*z 的大作中提到】 : percent return needs to be calc'ed, but not allowed to write function.
|
B*****g 发帖数: 34098 | 5 啥db。
啥version。
其实不用看了,google "over() partition by"
%
【在 a*z 的大作中提到】 : How to query stock price table (price in double) and return the the top 10% : of the highest percent return? : Thanks.
|
a*z 发帖数: 294 | 6 Thank you all for your info.
date price
1 12
2 23
3 10
...
I was asked to query the table in SQL 2005 to get the top 10% of performance
{(price - prior price)/price} without defining function. Thank you again. |
B*****g 发帖数: 34098 | 7 sql server 呀
SELECT TOP(10) PERCENT 。。。。。。。
performance
【在 a*z 的大作中提到】 : Thank you all for your info. : date price : 1 12 : 2 23 : 3 10 : ... : I was asked to query the table in SQL 2005 to get the top 10% of performance : {(price - prior price)/price} without defining function. Thank you again.
|
a*z 发帖数: 294 | 8 yes, I thought that.
select top 10 percent (price - lag(price))/price pctChange
from ....
order by pctChange
that pctChange needs to be calc'ed from price with 1 period lag. I do not
know if it works.
Thank you very much. |
c*******e 发帖数: 8624 | 9 qualify with rank/row_number() etc
%
【在 a*z 的大作中提到】 : How to query stock price table (price in double) and return the the top 10% : of the highest percent return? : Thanks.
|