欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

sql script: Calculating Days

程序员文章站 2022-05-23 23:26:37
...

T1 (ID INTEGER ) T1 VALUES ( 1 ) x(dy,dm,mth,dw,wk) 7 as ( 8 select dy, 9 day (dy) dm, 10 datepart (m,dy) mth, 11 datepart (dw,dy) dw, (dw,dy)(ww,dy) (ww,dy) 15 end wk 16 from ( (, getdate ()) dy 18 from t1 19 ) x (d, 1 ,dy), day ( dateadd

T1 (ID INTEGER) T1 VALUES (1) x(dy,dm,mth,dw,wk) 7 as( 8 select dy, 9 day(dy) dm, 10 datepart(m,dy) mth, 11 datepart(dw,dy) dw, (dw,dy)(ww,dy)(ww,dy) 15 end wk 16 from( (,getdate()) dy 18 from t1 19 ) x (d,1,dy),day(dateadd(d,1,dy)),mth, 22 datepart(dw,dateadd(d,1,dy)), (dw,(wk,(wk,dateadd(d,1,dy)) x (m,dateadd(d,1,dy))=mth 29 ) (dm end) as Mo, dm end) as Tu, dm end) as We, dm end) as Th, dm end) as Fr, dm end) as Sa, dm end) as Su 37 from x wk wk dy, 43 day(dy) dm, 44 datepart(m,dy) mth, 45 datepart(dw,dy) dw, (dw,dy)(ww,dy)(ww,dy) 49 end wk 50 from( (,getdate()) dy 52 from t1 53 ) x x(dy,dm,mth,dw,wk) 58 as( 59 select dy, 60 day(dy) dm, 61 datepart(m,dy) mth, 62 datepart(dw,dy) dw, (dw,dy)(ww,dy)(ww,dy) 66 end wk 67 from( (,getdate()) dy 69 from t1 70 ) x (d,1,dy), day(dateadd(d,1,dy)),mth, 73 datepart(dw,dateadd(d,1,dy)), (dw,(wk,(wk,dateadd(d,1,dy)) x (m,dateadd(d,1,dy))=mth 80 ) x ,网站空间,网站空间,网站空间