I'm trying to achieve this query in CubeJS which does a LEFT OUTER JOIN with itself.
SELECT COUNT(DISTINCT EC."accId")
FROM public."orders" EC
LEFT OUTER JOIN public."orders" NC
ON NC."accId" = EC."accId"
AND NC."isFirstOutletTransaction" = true
AND NC."occurredAt" > '2020-02-01'
AND NC."occurredAt" < '2020-03-01'
WHERE EC."occurredAt" > '2020-02-01'
AND EC."occurredAt" < '2020-03-01'
AND EC."isFirstOutletTransaction"=false
AND NC."accId" is null;
I'm stuck on how to express this in the CubeJS schema. Would appreciate the help. Thanks
You can create one cube called eg "FirstOutletTransatction" with the appropriate condition:
sql: 'select * from public."orders" NC where NC."isFirstOutletTransaction" = true'
then define the other cube eg "NonFirstOutletTransatction" like:
sql: 'select * from public."orders" NC where NC."isFirstOutletTransaction" = false'
Define the relation of the two cubes in their joins and add "occurredAt"
either as time dimension or in the query as a condition.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.