For example, the following is a multi-stars query on sales star and stock star. The two stars have date_dim and product_dim dimension tables in common. The top query joins the queries of the individual star on the common dimensions.
SELECT ...
FROM
(SELECT ...
FROM sales_fact sf, date_dim dd, store_dim sd, product_dim pd
WHERE
sf.dd_sk = dd.dd_sk
AND sf.sd_sk = sd.sd_sk
AND sf.pd_sk = pd.pd_sk
AND dd.month_name = "January"
AND dd.year = 2010
AND sd.store_name = "DownTown Branch"
AND pd.ISBN = 0975212826) sales
,
(SELECT ...
FROM inventory_fact if, date_dim dd, stock_location_dim sd, product_dim pd
WHERE
if.dd_sk = dd.dd_sk
AND if.sd_sk = sd.sd_sk
AND if.pd_sk = pd.pd_sk) stock
WHERE
sales.dd_sk = stock.dd_sk
AND sales.pd_sk = stock.pd_sk
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment