Guest User

Untitled

a guest
Jul 18th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. USE [GLCTest]
  2. GO
  3.  
  4. /****** Object: UserDefinedFunction [dbo].[GetMillDataByDate] Script Date: 11/25/2009 13:20:24 ******/
  5. SET ANSI_NULLS ON
  6. GO
  7.  
  8. SET QUOTED_IDENTIFIER ON
  9. GO
  10.  
  11.  
  12.  
  13.  
  14. -- =============================================
  15. -- Author: Erin Quick-Laughlin
  16. -- Create date: 11/24/2009
  17. -- Description: Collects all mill uptime and tons produced for a 24 hr period starting at @startDateTime
  18. -- =============================================
  19. ALTER FUNCTION [dbo].[GetMillDataByDate]
  20. (
  21. @startDateTime datetime
  22. )
  23. RETURNS TABLE
  24. AS
  25. RETURN
  26. (
  27. SELECT
  28. SUM(dbo.MinutesOnDate(met.StartTime,met.EndTime,@startDateTime)) AS Uptime,
  29. --SUM(mre.BeltScale * dbo.MinutesOnDate(met.StartTime,met.EndTime,@startDateTime)/met.MINUTES ) AS Tons,
  30. -- to do this for Mill or Classifier, we must get a list of all products in that run,
  31. -- get an average of the product's TonsPerHour
  32. -- multiply that avg TPH times the MinutesOnDate/60
  33. dbo.AvgTonsPerHourInMillRun(mre.Id) * SUM(dbo.MinutesOnDate(met.StartTime,met.EndTime,@startDateTime)) as Tons,
  34. dbo.ProductionMinutesOnDate(@startDateTime) AS ProductionMinutes
  35. --met.MillRecordId,
  36. --,SUM(mre.BeltScale) as BeltScaleSum
  37. --met.StartTime,
  38. --met.EndTime,
  39. --met.MINUTES
  40. FROM
  41. dbo.MillRunEvent AS mre
  42. INNER JOIN
  43. dbo.MillEventTimes AS met
  44. ON met.EventType = 'Run' AND mre.Id = met.OriginalId
  45. WHERE
  46. dbo.MinutesOnDate(met.StartTime,met.EndTime,@startDateTime) > 0
Add Comment
Please, Sign In to add comment