daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Nov 16th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE VIEW [dbo].[DeliverableProgress]
  2. WITH SCHEMABINDING
  3. AS
  4.     SELECT
  5.         M.DeliverableID,
  6.         IIF(
  7.             ISNULL(SUM(M.MilestoneWeight * MP.EventValue) / 100, 0) <= 100,
  8.             ISNULL(SUM(M.MilestoneWeight * MP.EventValue) / 100, 0),
  9.             100
  10.         ) AS CurrentProgress,
  11.         --- Just to make Index View happy, I have to add a COUNT_BIG. It does nothing.
  12.         COUNT_BIG(*) AS CNT
  13.     FROM dbo.Milestones M
  14.     INNER JOIN dbo.Events MP ON (MP.MilestoneID = M.MilestoneID OR MP.EventID =151604)
  15.         AND MP.EventTypeID = 9
  16.         AND MP.IsActive = 1
  17.         AND MP.IsCurrentProgress = 1
  18.     WHERE M.IsActive = 1
  19.     GROUP BY M.DeliverableID
  20. GO
  21.  
  22. CREATE UNIQUE CLUSTERED INDEX IX_DeliverableProgress
  23.     ON [dbo].[DeliverableProgress] ([DeliverableID])
RAW Paste Data
Top