_覓 | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁 |
|
[edit]
1 旧企? #れ企 旧 れ螻 螳 螻 .
伎 2005-06-15 殊 蟆 蟆一襯 . 蟆一 2005-08-05手讌襦 . 企 2005-08-05 蟾讌 覿豈襦 讌襷 覩碁Μ 蟆一襯 朱襦 旧 螳 . 企 螳 旧企手 . 襷 れ螻 螳 企 り 螳 覲伎.
譬襭 --------- -------- 20050615 20050805 蠏碁 蟆郁骸 れ螻 螳 . 蟆一 06 朱, 螳螳06, 07, 08企.
譬襭 蟆一 ---------- ---------- ---- ---- 20050615 20050630 06 06 20050701 20050731 06 07 20050801 20050805 06 08 [edit]
2 ろ碁一危 #CREATE TABLE #temp( AccountID varchar(20) , BeginDT char(8) , EndDT char(8) ) INSERT #temp VALUES('yasicom', '20050615', '20050805') INSERT #temp VALUES('yangdb', '20050515', '20050605') INSERT #temp VALUES('endless', '20060101', '20060601') INSERT #temp VALUES('mkex', '20070513', '20070730') GO [edit]
3 豌襴 SQL覓 #--貎朱Μ WITH Dumy(CF) AS ( SELECT 0 CF UNION ALL SELECT CF + 1 FROM Dumy WHERE CF + 1 <= 12 --1豺襷螻壱. ), MM(CF) AS ( SELECT CF FROM Dumy ) SELECT AccountID 螻 , YYYYMM + RIGHT('00' + BeginDD, 2) , YYYYMM + CASE WHEN RIGHT(YYYYMM, 2) <> SUBSTRING(EndDT, 5, 2) THEN RIGHT('00' + EndDD, 2) ELSE RIGHT(EndDT, 2) END 譬襭 , SUBSTRING(BeginDT, 5, 2) 蟆一 , RIGHT(YYYYMM, 2) FROM ( SELECT CONVERT(CHAR(6),DATEADD(mm, CF, BeginDT),112) YYYYMM , CONVERT(VARCHAR(2), CASE WHEN CF = 0 THEN DATEPART(dd, BeginDT) ELSE 1 END) BeginDD , CONVERT(VARCHAR(2), CASE WHEN CONVERT(CHAR(6), EndDT, 112) = CONVERT(CHAR(6), DATEADD(dd,-1, CONVERT(CHAR(6), DATEADD(mm,CF + 1, BeginDT),112) + '01' ),112) THEN DATEPART(dd,EndDT) ELSE DATEPART(dd, DATEADD(dd, -1, CONVERT(CHAR(6),DATEADD(mm,CF + 1, BeginDT), 112)+'01')) END) EndDD , BeginDT , EndDT , AccountID FROM #temp A CROSS JOIN (SELECT CF FROM MM) B WHERE CF <= DATEDIFF(mm, BeginDT, EndDT) ) T ORDER BY 螻,
鏤
|
螳讌襦 襯 觸願鍵 覲企 觜襦 覲願鍵 覲狩讌襷 訖襴襯 企Μ蠍 磯 螳 . |