SQL DataFlows

SQL DataFlows

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

image.png

transform_data_current

image.png

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

image.png
Tagged:

Answers

  • 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.

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In