SQL Dataflow - Left join reduces number of rows in left table

Hi, I am trying to join 2 tables based on a "date - product" —> columns "year_month_key" and "year_month_lagged_key"

My 2 tables are the following

transform_data_lagged

transform_data_current

when i join both table via the following left join statement, i loose the first rows in the left table, "transform_data_lagged", because there is no match in the second table I am joining with. But from my understanding the left join should have kept all rows from the left table, or not?

SELECT a.* from transform_data_lagged a
left OUTER JOIN transform_data_current b on a.year_month_lagged_key = b.year_month_key

Tagged:

Answers

  • ColemenWilson
    edited January 22

    If I solved your problem, please select "yes" above

  • resolved. This was just an issue of the sorting. All rows from the left table were kept, but automatically pushed to the very bottom of the output table. Thereby i didn't see those rows. Order by revealed this to me.