-- ================================================ -- Template generated from Template Explorer using: -- Create Inline Function (New Menu).SQL -- -- Use the Specify Values for Template Parameters -- command (Ctrl-Shift-M) to fill in the parameter -- values below. -- -- This block of comments will not be included in -- the definition of the function. -- ================================================ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: -- Create date: -- Description: -- ============================================= CREATE FUNCTION NumberOfPI ( -- Add the parameters for the function here @att1 varchar(50), @att2 varchar(50) ) RETURNS INT AS BEGIN DECLARE @numPI INT; SELECT @numPI = count(distinct a1.value) FROM events as e1, events as e2, correlationAttributes as a1, correlationAttributes as a2 WHERE a1.attribute = @att1 and a2.attribute = @att2 and a1.value=a2.value AND a1.value<>'' AND a1.value IS NOT NULL AND a2.value<>'' AND a2.value IS NOT NULL and a1.idEvent<>a2.idEvent and a1.idEvent=e1.id and a2.idEvent=e2.id AND e1.timestamp