根据日期增加记录?

时间:2017-01-09 15:30:49

标签: sql tsql

我有一个查询

module = import_module('directory')
for name, klass in inspect.getmembers(module):
    if name.startswith('__') or not inspect.isclass(klass): continue
    instance = klass()
    run_fn = getattr(instance, 'run', None)
    if run_fn and callable(run_fn):
        run_fn()

将结果集设为:

SELECT ROW_NUMBER() OVER (PARTITION BY [CLIENT NO] ORDER BY Business_Date ASC) AS AGE_IN_DAYS,* 
FROM #TEMP 
WHERE COLLATERAL_VALUE < 0 AND [CLIENT NO] = 'XXXXXX'

我需要根据GEA_IN_DAYS CLIENT NO MARKET_VALUE COLLATERAL_VALUE Business_Date PERSHING ID 1 xxxxx -3102.37 -332884.83 12/13/2016 2VX031579 2 xxxxx -4963.8 -334467.04 12/14/2016 2VX031579 3 xxxxx -17952.41 -345507.36 12/15/2016 2VX031579 4 xxxxx -428.28 -428.28 12/22/2016 2VX031579 更新列AGE_IN_DAYS。 如果Business_date是连续的,我需要通过&#39; 1&#39;更新Business_date。 在上面的例子中,我需要通过&#39; 1&#39;增加前3个记录。最后一个我需要从1开始再次计算。

任何人都可以建议我怎么做?

0 个答案:

没有答案