asked on
ASKER
select
thedate,
weekend_or_holiday,
workdaynum= CASE weekend_or_holiday
WHEN 1 THEN (SELECT COUNT(td.weekend_or_holiday) FROM tbldates tbldb WHERE tbldb.thedate<tblda.thedate AND DATEPART(m,tbldb.thedate)=DATEPART(m,tblda.thedate)) AND weekend_or_holiday=0
ELSE row_number() over (
partition by datediff(m,0,thedate), weekend_or_holiday
order by thedate) end
from tbldates tblda
order by thedate
select
thedate,
weekend_or_holiday,
workdaynum= CASE weekend_or_holiday
WHEN 1 THEN
(SELECT
COUNT(td.weekend_or_holiday)
FROM tbldates tbldb
WHERE tbldb.thedate<tblda.thedate
AND DATEPART(m,tbldb.thedate)=DATEPART(m,tblda.thedate) AND weekend_or_holiday=0)
ELSE row_number() over (
partition by datediff(m,0,thedate), weekend_or_holiday
order by thedate) end
from tbldates tblda
order by thedate
ASKER
ASKER
ASKER
ASKER
Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.
TRUSTED BY