Sql 从指数中获得看涨趋势
我需要股票交易数据的看涨趋势。数据就像Sql 从指数中获得看涨趋势,sql,sql-server-2008,stock,Sql,Sql Server 2008,Stock,我需要股票交易数据的看涨趋势。数据就像 ticker date open high low AABS 2014-03-06 98.20 97.40 98.20 AABS 2014-03-05 98.01 96.01 98.91 AABS 2014-03-04 97.00 97.00 96.07 AA
ticker date open high low
AABS 2014-03-06 98.20 97.40 98.20
AABS 2014-03-05 98.01 96.01 98.91
AABS 2014-03-04 97.00 97.00 96.07
AATM 2014-03-06 7.43 6.35 7.43
AATM 2014-03-05 6.00 5.00 5.00
AATM 2014-03-04 5.28 4.55 4.60
AATM 2014-03-03 7.45 3.20 7.30
我需要的解决方案是,对于每个股票代码和最近的日期,检查未平仓、高点和低点的趋势,如果它们是从以前的日期开始增加的,并且从多少天开始增加。
因此,结果集将是
ticker date opnTrend highTrend lowTrend
AABS 2014-3-06 2 1 0
AATM 2014-3-06 2 4 3
如果您有任何帮助,我们将不胜感激。到目前为止,您尝试了什么?我尝试了使用带有递归的CTE(common table express),但没有找到解决方法。