Skip to main content

Hi all


I have a very basic question – sorry for that, I’m quite new to PQL and I cannot apply the information available online (or did not find it).


I have two tables incident_CASE with column CASE_ID (1-side) and workorder_CASE with column WORKORDER_ID (n-side) (1 incident can have 1 or more workorder).


How can I count the following:

  • Number of incidents with exactly 1 workorder
  • Number of incidents with 2 or more workorder

 

Many thanks for your support
Best
roger


    COUNT_TABLE(
        FILTER "incident_CASE"
        WHERE COUNT_DISTINCT(
            "workorder_CASE"."WORKORDER_ID",
            "workorder_CASE"."CASE_ID" = "incident_CASE"."CASE_ID"
        ) = 1
    )

    COUNT_TABLE(
        FILTER "incident_CASE"
        WHERE COUNT_DISTINCT(
            "workorder_CASE"."WORKORDER_ID",
            "workorder_CASE"."CASE_ID" = "incident_CASE"."CASE_ID"
        ) >= 2
    ) 

 

The above two PQL expressions should function as intended. Please ensure that the corresponding tables are properly connected in the backend before execution.


Reply