我有一个货币汇率表,其格式类似于以下内容:
asofdate currency spot fwd1m fwdyield rank_
1999-03-26 00:00:00.000 EUR 0.93161900 0.93340000 1.001911725716199433459 1
1999-03-26 00:00:00.000 NOK 7.80300000 7.81630000 1.001704472638728694092 2
1999-03-26 00:00:00.000 CAD 1.51350000 1.51355000 1.000033036009250082590 3
1999-03-26 00:00:00.000 AUD 1.57728700 1.57713800 0.999905533996032427833 4
1999-03-26 00:00:00.000 NZD 1.86828600 1.86748300 0.999570194285029165770 5
1999-03-26 00:00:00.000 GBP 0.61728400 0.61665000 0.998972920082166393426 6
1999-03-26 00:00:00.000 SEK 8.33400000 8.32080000 0.998416126709863210943 7
1999-03-26 00:00:00.000 CHF 1.48480000 1.48007000 0.996814385775862068965 8
1999-03-26 00:00:00.000 JPY 120.09000000 119.60550000 0.995965525855608293779 9
1999-05-26 00:00:00.000 EUR 0.95438100 0.95662000 1.002346023233907632276 1
1999-05-26 00:00:00.000 NOK 7.85100000 7.86505000 1.001789580945102534708 2
1999-05-26 00:00:00.000 AUD 1.54154500 1.54147300 0.999953293611279592875 3
1999-05-26 00:00:00.000 CAD 1.47330000 1.47307000 0.999843887870766306930 4
从这个表中,我想保留每个日期的排名(基于 fwdyield 字段)的 TOP 和 BOTTOM 3 记录。
输出看起来像这样,但会包括初始表中存在的每个日期:
asofdate currency spot fwd1m fwdyield pos
1999-03-26 00:00:00.000 JPY 120.09000000 119.60550000 0.995965525855608293779 -1
1999-03-26 00:00:00.000 CHF 1.48480000 1.48007000 0.996814385775862068965 -1
1999-03-26 00:00:00.000 SEK 8.33400000 8.32080000 0.998416126709863210943 -1
1999-03-26 00:00:00.000 CAD 1.51350000 1.51355000 1.000033036009250082590 1
1999-03-26 00:00:00.000 NOK 7.80300000 7.81630000 1.001704472638728694092 1
1999-03-26 00:00:00.000 EUR 0.93161900 0.93340000 1.001911725716199433459 1
挑战在于为每个日期执行此操作,以避免需要使用循环/光标。想法?