OIS Skrevet 24. mars 2009 Del Skrevet 24. mars 2009 Vilkårlig kode fra pastebin.com. select datepart (ww,dateadd(d,day_number,convert(datetime,'2009-01-01',102))) as week_number , dateadd(d,day_number,convert(datetime,'2009-01-01',102)) as data_licz -- , datepart (dw,dateadd(d,day_number,convert(datetime,'2009-01-01',102))) as day_week_number , dateadd(d,day_number + (7 - datepart (dw,dateadd(d,day_number,convert(datetime,'2009-01-01',102)))),convert(datetime,'2009-01-01',102)) as data_licz_e from ( select l, (ROW_NUMBER ( ) over (ORDER BY l DESC)) - 1 as day_number from ( SELECT top 366 derivedtbl_2.Expr1 AS l FROM (SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1) AS derivedtbl_1 CROSS JOIN (SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1) AS derivedtbl_2 CROSS JOIN (SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1 UNION ALL SELECT 1 AS Expr1) AS derivedtbl_3 ) as t ) as tt where datepart (dw,dateadd(d,day_number,convert(datetime,'2009-01-01',102))) = 1 or day_number = 1 Lenke til kommentar
Anbefalte innlegg