This is a bit of a weird question, but I will explain the problem first.
Every day we import a refreshed set of data in to a table called MARKETABLE_TABLE.
Sometimes there is an error with the generated data, and it has fewer records (say 400k instead of 800k).
Currently I am having to manually re-import the previous day's data when that happens, as having all the older data is better than having 60% of new data.
What I am trying to do:
I have a built 2 copies of the main data extension, MARKETABLE_TABLE_YESTERDAY and MARKETABLE_TABLE_TODAY.
After doing the import, I copy everything to the MARKETABLE_TABLE_YESTERDAY table. The next day, a new import happens to the MARKETABLE_TABLE_TODAY table.
I then want to have a query run that looks at the rowcounts for these 2 tables.
If MARKETABLE_TABLE_YESTERDAY > MARKETABLE_TABLE_TODAY, copy everything from MARKETABLE_TABLE_YESTERDAY in to MARKETABLE_TABLE and continue with the automation.
If MARKETABLE_TABLE_YESTERDAY <= MARKETABLE_TABLE_TODAY, copy everything from MARKETABLE_TABLE_TODAY in to MARKETABLE_TABLE and continue with the automation.
Is it even possible to have 2 different SELECT statements within an IF statement comparing the size of the 2 tables, with the query itself always writing to a single final table?
Thanks