cubes
cubes copied to clipboard
Subquery to facts table
Hello, guys!
I need to have all items from dimension table with or without joined facts from facts table. So I need to construct a subquery to facts table with RangeCut or any other cut. It is important to filter fact table before joining.
I need to execute the following SQL query:
SELECT T.id, coalesce(sum(T.value), 0)
FROM dim_table
LEFT OUTER JOIN (
SELECT * FROM fact_table WHERE EXTRACT(YEAR FROM fact_table.date) >= 2017
) as T ON T.dim_id = dim_table.id
WHERE ...
GROUP BY ...
ORDER BY ...
How to do that with cubes framework?