drop table migrate_tax_transactions;

create table migrate_tax_transactions as select vt.id, vt.vehicle vehicle_id, tt.partner_id, tt.date_due, tt.date_invoice, tt.date_invoice create_date, tqc.quarter , qy.name tax_year, vt.tax_number vt_tax_number, lc.name tax_number, lc.id tax_sticker_id, tt.invoice_id, tt.invoice_status, tt.ai_number, tt.amount_total
                from migrate_title_transactions tt
                join vehicle_tax vt on tt.vehicle_id = vt.vehicle
                join tax_quarter_color tqc on vt.quarterly_tax_id  = tqc.id
                join quarter_year qy on tqc.year  = qy.id
                full outer join label_code lc on lc.id = vt.label_id
                where tt.id is not null
                order by tt.id;

