
CREATE VIEW [dbo].[ApiUnfinishedProdActivities] as
select runAct.* from dbo.ApiProdActivities runAct
where 
 StateId in (20,40) and
NOT EXISTS ( select * from dbo.ApiProdActivities stopActt where stopActt.StartActivityId = runAct.Id and stopActt.OperationId = runAct.OperationId )
GO


