因此,每当我有共同的“ J No”时,我想执行以下计算:
仅取“ Setup Start”中的第一个值,并将其与“ Run Start”和“ Run End”中的最后两个值合并,并删除它们之间的任何记录。
这是我的查询代码:
SELECT
[LineNo]
,[J No]
,[FC]
,[SetupStart]
,[UpTimeStart]
,[UpTimeEnd]
,[Setup]
,[UpTime]
,[Targ Len]
,[Act Len]
,[R Up F]
,[R Dn F]
,[Scrap]
FROM [Initial].[dbo].[vWGetProductionInfo]
ORDER BY SetupStart ASC, UpTimeEnd AS
我该如何修改此查询以提供上面列出的所需输出?
答案 0 :(得分:1)
松鼠提到的类似东西
SELECT [J No]
,MIN([SetupStart]) AS [SetupStart]
,MAX(UpTimeStart) AS UpTimeStart
,MAX(UpTimeEnd) AS UpTimeEnd
FROM [Initial].[dbo].[vWGetProductionInfo]
GROUP BY [J No]