通过SSRS SQL Server 2012更新的正常运行时间/停机时间生产批处理报告

问题描述 投票:2回答:1

我正在使用SSRS通过Visual Studio 2010编写另一份报告。我是SQL的新手,但随着时间的推移,事情开始变得有意义了。

目的是创建一个报告,显示从SQL Server数据库中获取的Batch up time / downtime计算的timestamps。时间戳表示为日期/时间输入,例如2018-02-09 14:43:29.193

必须满足4个事件ID 1-4才能触发数据库中的时间戳。每批都有自己的3位整数ID。

1-Batch Start, Not running production, but system is initiated. (Down)
2-Production Start, Running production (Up Time)
3-Production Stop, Machine is running, but not producing (Down)
4-Batch Stop, Production complete. (Down)

和...之间的不同,

2&1 = Downtime
4&1 = Downtime
2&3 = Up time
If 4 is after 2 = Up time
If 4 is after 3 = Downtime

Database

我已经尽力使用这份知识有限的报告,并且在报告中我创建了参数来选择报告的日期,并要求用户选择批次ID以及批处理1-4事件,但我不确定如何处理计算字段。

下面是SQL代码,

 /****** Script for SelectTopNRows command from SSMS  ******/
SELECT TOP 1000 
    [Productio_CrtNo]
  , [BatchEvent_ID]
  , [BatchEvent_TIME]
  , [Operator_ID]
  , [DieRolls_ID]
  , [Batch_ID]
  , [NoOfPockets]
  , [WetCapsulesWeight]
FROM [SCM_DataCollecion].[dbo].[ProductionTable] 

Current Report

我一直在阅读旋转表,我认为这可能是计算up / downtime的方法,但是我需要一些帮助。

再次感谢

sql-server visual-studio reporting-services uptime downtime
1个回答
0
投票

我有三种方法可以解决这个问题。

  1. 根据3位数的id号在SQL中使用排名
  2. 根据事件ID在SQL中使用Pivot
  3. 使用矩阵执行数据透视并在报表中执行计算。
© www.soinside.com 2019 - 2024. All rights reserved.