[英]LEFT OUTER JOIN with CubeJs
I'm trying to achieve this query in CubeJS which does a LEFT OUTER JOIN with itself.我正在尝试在 CubeJS 中实现这个查询,它与自己进行 LEFT OUTER JOIN。
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.我被困在如何在 CubeJS 模式中表达这一点。 Would appreciate the help.
将不胜感激的帮助。 Thanks
谢谢
You can create one cube called eg "FirstOutletTransatction" with the appropriate condition:您可以使用适当的条件创建一个名为“FirstOutletTransatction”的多维数据集:
sql: 'select * from public."orders" NC where NC."isFirstOutletTransaction" = true'
then define the other cube eg "NonFirstOutletTransatction" like:然后定义另一个立方体,例如“NonFirstOutletTransatction”,如:
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.在连接中定义两个多维数据集的关系,并添加
"occurredAt"
作为时间维度或在查询中作为条件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.