0
目前有一個腳本可以像這樣選擇一年中的前5個月。在SQL Select Index中編制索引
...
;WITH months AS
(
-- we need 5 months
SELECT TOP (5) m = number FROM master.dbo.spt_values
WHERE type = 'P' ORDER BY number
),
-- we need a week in each month, starting at the 1st
weeks AS (SELECT w FROM (VALUES(0),(1),(2),(3)) AS w(w)),
dates AS
(
-- this produces a date for the first 4 weeks of each
-- month from the start date
SELECT d = DATEADD(WEEK,w.w,DATEADD(MONTH,m.m,@start))
FROM months AS m CROSS JOIN weeks AS w
),
...
我該如何修改此腳本只需要1,2,4,5個月。
再次感謝亞倫 –
亞倫是男人。 – Kermit