Correct the query

  • Hi Dear,

    Please help me.

    when i m running this query it displays error.

    If someone correct this query then it will very greatful for me.

    Thank in advance.

    (SELECTdistinct PD.DependentProcessid

    FROMProcessDependencies PD

    LEFT JOIN Processes P ON

    PD.ProcessId=P.ProcessId

    INNER JOIN ProcessGroup PG ON

    P.ProcessGroupID=PG.ProcessGroupID

    ANDPG.OrderID<5

    ANDPD.Processid=10

    ANDPD.DependencyType='B')as P2

    SELECTP1.ProcessID,

    CASE WHEN BEGIN P1.Processid=P2.DependentProcessid THEN 1 ELSE 0 END

    FROMProcesses P1

  • what are you trying to achieve, what is the error message?

    MVDBA

  • Yes, your query looks very confusing. are trying to write CTE?

    like

    with P2 as

    (SELECT distinct PD.DependentProcessid

    FROM ProcessDependencies PD

    LEFT JOIN Processes P ON

    PD.ProcessId=P.ProcessId

    INNER JOIN ProcessGroup PG ON

    P.ProcessGroupID=PG.ProcessGroupID

    AND PG.OrderID<5

    AND PD.Processid=10

    AND PD.DependencyType='B')

    SELECT P1.ProcessID,

    CASE WHEN P1.Processid=P2.DependentProcessid THEN 1 ELSE 0 END

    FROM Processes P1

    Is this what you are trying to do?

    ----------------------------------------------------------------------------------------------------------------------------------------------------
    Roshan Joe

    Jeff Moden -Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Thanks u very much dear it's working fine

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply