大家好我想选择'end_date_service_fk'和'invoice_date_fk',这是与同一个表'dim_time'相关的两个外键我使用这个带有别名e1和e2的SQL脚本来区分这两个外键但是它仍然没有返回正确的结果。
你能帮我找到解决方案吗?
SELECT
sum(itics."service_price"),
sum(itics."service_quantity"),
engagement_code,
engagement_name,
functional_name,
service_name,
e1.day_date,
e2.day_date
FROM
spokes."fact_itics" itics INNER JOIN spokes."dim_engagement" ON itics."engagement_fk" = spokes."dim_engagement"."engagement_sk"
INNER JOIN spokes."extra_fact_itics" ON itics."extra_fact_itics_fk" = spokes."extra_fact_itics"."extra_fact_itics_sk"
INNER JOIN spokes."dim_service" ON itics."service_fk" = spokes."dim_service"."service_sk"
inner join spokes."dim_time" e1 ON itics."end_date_service_fk" = e1."date_sk"
inner join spokes."dim_time" e2 on itics."invoice_date_fk" = e2."date_sk"
WHERE
e1.date_sk = e2.date_sk
GROUP BY
engagement_code,
engagement_name,
functional_name,
service_name,
e1.day_date,
e2.day_date