题目要求自己写的sqlselecta.datetime as 年月,a.entry_num as 入职人数,b.entry_num as 上月入职人数,b.entry_num as 上年同期入职人数 from (select te.year, te.month,te.datetime,te.entry_num from (select left(datetime,4) as year ,SUBSTR(datetime,6,2) as month ,datetime,entry_num,leave_num from student_2007 ) as te where te.year = '2019' order by te.month) aleft join (select te.year, te.month,te.datetime,te.entry_num from (select left(datetime,4) as year ,SUBSTR(datetime,6,2) as month ,datetime,entry_num,leave_num from student_2007 ) as te where te.year = '2018' order by te.month) bon a.year=b.year+1and a.month=b.monthwhere a.year = '2019'问题 datetime数据类型是varchar类型的 评论区测试一测试二