Try OpenEdge Now
skip to main content
Multi-tenancy Overview
Multi-tenancy and OpenEdge SQL : Super tenant use cases : Join multi-tenant tables
 

Join multi-tenant tables

To join three multi-tenant tables, pub.mtcustomer, pub.mtorder, and pub.mtorderline:
SELECT
    tenantName_tbl (c) as ten_name,
    c.name as c_name,
    COUNT (*)
FROM
    Pub.mtcustomer AS c
    INNER JOIN pub.mtorder AS o
    ON tenantId_tbl (c) = tenantId_tbl (o)
    AND c.custnum = o.custnum
    INNER JOIN pub.mtorderline AS ol
    ON tenantId_tbl (o) = tenantId_tbl (ol)
    AND o.ordernum = ol.ordernum
GROUP BY
    ten_name, c_name;