亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

連續逾期

發布時間:2020-03-14 19:38:04 來源:網絡 閱讀:262 作者:Kassadar 欄目:關系型數據庫

IF EXISTS(SELECT FROM SYS.TABLES WHERE NAME='SPD') DROP TABLE SPD;
WITH CTE1 AS
(
SELECT
IIF(PD_DueDT>=ISNULL(PD_DebitSuccDT,'9999-12-31'),0,1) AS FLAG/
逾期FLAG/,
ROW_NUMBER() OVER(PARTITION BY PD_EFH_SN ORDER BY PD_Termth) AS ID/
期次序號/,
MAX(PD_Termth) OVER (PARTITION BY PD_EFH_SN)AS CurrID/
當前最大期次序號*/,

  • FROM PD WHERE PD_DueDT<=GETDATE() AND PD_Termth>0
    ),
    CTE2 AS
    (
    SELECT
    SUM(FLAG) OVER(PARTITION BY PD_EFH_SN ORDER BY PD_Termth ROWS UNBOUNDED PRECEDING) AS AccuFlag/累計逾期期次/,

  • FROM CTE1
    ),
    CTE3 AS
    (
    SELECT
    ID-AccuFlag AS FlagGrp/逾期分組/,

  • FROM CTE2
    ),
    CTE4 AS
    (
    SELECT
    SUM(FLAG) OVER (PARTITION BY PD_EFH_SN,FlagGrp) AS CountFlag/分組計數/,

  • FROM CTE3 WHERE FLAG=1
    ),
    CTE5 AS
    (
    SELECT
    MAX(CountFlag) OVER (PARTITION BY PD_EFH_SN) AS MaxContFlag/最大連續/,
    MAX(AccuFlag) OVER (PARTITION BY PD_EFH_SN) AS TotFlag/歷史累計/,
    IIF(ID=PD_TotTerm,CountFlag,0) AS CurrContFlag/當前累計/,
    ROW_NUMBER() OVER (PARTITION BY PD_EFH_SN ORDER BY PD_Termth DESC) AS CurrTermth,

  • FROM CTE4
    )
    SELECT DISTINCT PD_EFH_SN,MaxContFlag,TotFlag,CurrContFlag,'XFY' AS DataSource INTO SPD FROM CTE5 WHERE CurrTermth=1

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

巴南区| 五常市| 西乌| 霸州市| 安乡县| 中卫市| 澳门| 龙州县| 贺兰县| 惠州市| 郑州市| 鄂托克前旗| 永善县| 北宁市| 阿克陶县| 宜黄县| 寿阳县| 焦作市| 大名县| 潼关县| 象山县| 石屏县| 彩票| 怀柔区| 来安县| 馆陶县| 洮南市| 望都县| 株洲市| 家居| 洛川县| 惠安县| 德钦县| 定结县| 邛崃市| 邢台县| 克山县| 乌兰浩特市| 正安县| 洛阳市| 绩溪县|