Thursday, May 28, 2015

Where did that join condition come from?

Being a consultant, I see many different MSTR implementations and the following issue pops up ever so often.

A report that always works, suddenly... doesn't.

After checking the change log (no changes were made to the report) and making sure there is data in the warehouse, I find an interesting addition to the report SQL.
Where it was always:

SELECT a1.day
FROM
Fact a1
join LU_Date a2
on a1.day = a2.day

now it is...

SELECT a1.day
FROM
Fact a1
join LU_Date a2
on a1.day = a2.day 
and a1.deliverydate = a2.day

Where did the additional join condition come from?