34,594
社区成员
发帖
与我相关
我的任务
分享
select
Log_a.*
from dbo.NFLog Log_a
join dbo.NFLog Log_b
on Log_a.StationId = Log_b.StationId
and Log_a.EquipmentId = Log_b.EquipmentId
and Log_a.EventId = Log_b.EventId
and Log_a.EventConditionId = Log_b.EventConditionId
and Log_a.StartTime = Log_b.StartTime
--and Log_a.[NotificationLogId] != Log_b.[NotificationLogId]
where Log_a.EventStatus != Log_b.EventStatus;
--1
select *
from NFLog t
where exists (select 1 from NFLog where StationId = t.StationId and EquipmentId = t.EquipmentId
and EventId = t.EventId and EventConditionId = t.EventConditionId and StartTime = t.StartTime
and EventStatus <> t.EventStatus)
--2
select *
from NFLog t
where not exists (select 1 from NFLog where StationId = t.StationId and EquipmentId = t.EquipmentId
and EventId = t.EventId and EventConditionId = t.EventConditionId and StartTime = t.StartTime
and EventStatus = 2)
and EventStatus = 1
--1
select *
from NFLog t
where exists (select 1 from NFLog where StationId = t.StationId and EquipmentId = t.EquipmentId
and EventId = t.EventId and EventConditionId = t.EventConditionId and StartTime = t.StartTime
and EventStatus <> t.EventStatus)
--2
select *
from NFLog t
where not exists (select 1 from NFLog where StationId = t.StationId and EquipmentId = t.EquipmentId
and EventId = t.EventId and EventConditionId = t.EventConditionId and StartTime = t.StartTime
and EventStatus = 2)
and EventStatus = 1