weaver-hrm-salary/resource/sqlupgrade/PG/sql202308160103.sql

22 lines
799 B
SQL

create table hrsa_acct_tax_agent
(
id bigint primary key ,
create_time timestamp,
update_time timestamp,
creator bigint,
delete_type int default 0,
tenant_key varchar(10),
salary_acct_record_id bigint,
tax_agent_id bigint,
salary_month timestamp,
tax_cycle timestamp,
income_category varchar(100)
);
/
insert into hrsa_acct_tax_agent(id, create_time, update_time, creator, tenant_key, salary_acct_record_id, income_category, tax_agent_id, salary_month, tax_cycle)
select id, create_time, update_time, creator, tenant_key, salary_acct_record_id, income_category, tax_agent_id, salary_month, tax_cycle
from hrsa_salary_acct_emp
where delete_type = 0
and id in (select max(id) from hrsa_salary_acct_emp group by salary_acct_record_id, income_category, tax_agent_id, tax_cycle);
/