This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Filtering in SQL

FormerMember
FormerMember

I Have this SQL script

SELECT
    StartTime.EventTime,
   
    Nodes.Caption,
    DATEDIFF(Mi, StartTime.EventTime,
    (SELECT TOP 1
        EventTime
        FROM Events AS Endtime
        WHERE EndTime.EventTime > StartTime.EventTime AND EndTime.EventType = 5
            AND EndTime.NetObjectType = 'N'
            AND EndTime.NetworkNode = StartTime.NetworkNode
        ORDER BY EndTime.EventTime)) AS DurationInMinutes


FROM Events StartTime INNER JOIN Nodes ON StartTime.NetworkNode = Nodes.NodeID
WHERE (StartTime.EventType = 1) AND (StartTime.NetObjectType = 'N')
ORDER BY StartTime.EventTime DESC

How can I filter this script with a specific Node and the Duration is null?

  • i think i got the NODE piece but i'm still working on the Duration. the percent part is wildcard of course. remove it and use your exact node name.

    i'm not a SQL person but i'll give anything a try...

    SELECT
        StartTime.EventTime,
       
        Nodes.Caption,
        DATEDIFF(Mi, StartTime.EventTime,
        (SELECT TOP 1
            EventTime
            FROM Events AS Endtime
            WHERE EndTime.EventTime > StartTime.EventTime AND EndTime.EventType = 5
                AND EndTime.NetObjectType = 'N'
                AND EndTime.NetworkNode = StartTime.NetworkNode
            ORDER BY EndTime.EventTime)) AS DurationInMinutes


    FROM Events StartTime INNER JOIN Nodes ON StartTime.NetworkNode = Nodes.NodeID
    WHERE (StartTime.EventType = 1) AND (StartTime.NetObjectType = 'N')

    AND Nodes.Caption LIKE 'MyNodesNamed%'
    ORDER BY StartTime.EventTime DESC

  • FormerMember
    0 FormerMember in reply to lchance

    Thanks for the response. We will appreciate if you can give us the script for this problem. Really need it.

  • seems to avoid the NULL if you use it this way.

    change your AND EndTime.EventType = 5

    to this

    AND NodeID > 1