Replace DATE('now', '-7 days', 'weekday 1') with the more robust DATE('now', '-' || ((strftime('%w', 'now') + 6) % 7) || ' days', '-7 days')
Also clarified question Which cars were in inventory in the latest snapshot for march 2023? Return the car id, make, model, and year. with additional line Cars are considered to be "in inventory" if is_in_inventory is True. Model always missed out this criteria because it may have assumed that being in the inventory_snapshots snapshots automatically meant it's in inventory.
DATE('now', '-7 days', 'weekday 1')
with the more robustDATE('now', '-' || ((strftime('%w', 'now') + 6) % 7) || ' days', '-7 days')
Which cars were in inventory in the latest snapshot for march 2023? Return the car id, make, model, and year.
with additional lineCars are considered to be "in inventory" if is_in_inventory is True.
Model always missed out this criteria because it may have assumed that being in theinventory_snapshots
snapshots automatically meant it's in inventory.