Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
WITH t1 AS (
  SELECT cm_identifiers.id,cm_identifiers.actor_identifier,cm_org_identities.co_id
  FROM cm_identifiers
  INNER JOIN cm_org_identities on cm_identifiers.org_identity_id=cm_org_identities.id
  WHERE cm_identifiers.actor_identifier IN (
    SELECT username
    FROM cm_api_users
    WHERE co_id > 1
    AND privileged = true
  )
), t2 AS (
  SELECT username,co_id
  FROM cm_api_users
  WHERE co_id > 1
  AND privileged = true
)
SELECT * FROM t1
  LEFT JOIN t2 on t1.actor_identifier=t2.username
  WHERE t1.co_id <> t2.co_id;

...