There may be other issues, but one detail is that likely you need to distinguish the references to the [Product] columns between the two tables. Analogously, you may likely need [_THISROW] also for your references to [start_date] and [end_date] columns. Within the SELECT function the default context for any column reference is the table from the function’s first argument (e.g., Sales)–not the table where the expression happens to be.