本文介绍了SQL日期比较和重复数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



我目前正忙于为客户报告。



报告很好,有一个问题。

我有数据通过txt文件导入系统,与我的程序中某些阶段完成的工作进行比较。



客户现在已经在报告中要求如果项目在一天内多次通过特定阶段,则报告应该仅显示项目第一次通过该阶段当前我的查询是


Hi

I am currently busy on some reporting for a client.

The data for the report is fine there is one problem.
I have data which is being imported to the system via txt documents which is compared to work which is completed at certain stages in my program.

The client has now requested that on the report if the item passes a particular stage more than once in a day the report should only show the first time the item has passed that stage currently my query is

SELECT DISTINCT
                      dbo.LIstAllStages.Serial, dbo.LIstAllStages.type, dbo.LIstAllStages.type2, dbo.LIstAllStages.Symptom, dbo.LIstAllStages.Comment,
                      dbo.ImportFile.CodeGroup, dbo.Importfile.Code, dbo.ImportFile.comment,
                      dbo.LIstAllStages.WorkCompleted, dbo.LIstAllStages.Stage
FROM         dbo.ImportFile INNER JOIN
                      dbo.LIstAllStages ON dbo.ImportFile.serial COLLATE Latin1_General_CI_AS = dbo.LIstAllStages.Serial
WHERE     dbo.LIstAllStages.Stage = 'SSH'
UNION ALL
SELECT DISTINCT
                      dbo.LIstAllStages.Serial, dbo.LIstAllStages.type, dbo.LIstAllStages.type2, dbo.LIstAllStages.Symptom, dbo.LIstAllStages.Comment,
                      dbo.ImportFile.CodeGroup, dbo.Importfile.Code, dbo.ImportFile.comment,
                      dbo.LIstAllStages.WorkCompleted, dbo.LIstAllStages.Stage
FROM         dbo.ImportFile INNER JOIN
                      dbo.LIstAllStages ON dbo.ImportFile.serial COLLATE Latin1_General_CI_AS = dbo.LIstAllStages.Serial
WHERE     dbo.LIstAllStages.Stage = 'SHS'


Please assist in how i could show just the first time the serial will show based on the workcompleted date.

推荐答案



这篇关于SQL日期比较和重复数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 20:11
查看更多