参考
select a.*,b.同期 from (select substr(入职日期,6,2) m,入职日期,入职人数 from aTQ where substr(入职日期,1,4)='2019') a
left join (select substr(入职日期,6,2) m,入职日期,入职人数 as 同期 from aTQ where substr(入职日期,1,4)='2018' ) b on a.m=b.m

原始数据

=================
select a.*,b.同期,c.上期 from (select substr(入职日期,6,2)*1 m,入职日期,入职人数 from aTQ where substr(入职日期,1,4)='2019') a
left join (select substr(入职日期,6,2)*1 m,入职日期,入职人数 as 同期 from aTQ where substr(入职日期,1,4)='2018' ) b on a.m=b.m
left join
(select substr(入职日期,6,2)+1 m,入职日期,入职人数 as 上期 from aTQ where substr(入职日期,1,4)='2019'
union
select (case when substr(入职日期,6,2)*1=12 then 1 end) m,入职日期,入职人数 as 上期 from aTQ where substr(入职日期,1,4)='2018'
) c on a.m=c.m
