Skip to content
Advertisement

How to join two tables using partition (or something else)

I have two tables:

  • table A with sales products (test1, test2) with every day information
  • table B with history of category changes of these products (product can change category once a year or every day, it depends on products)

And I want to have sales with current categories of products to this day (if category changed today i want to see it to this day and later, before next change)

Please help without many subqueries (tables are heavy)

Advertisement

Answer

Below is for BigQuery Standard SQL

If to apply to sample data from your question – result is

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement