以下是我改动后的,你看是否能正确执行:selectcount(t.belongcity)cntfrompolitical_baseinfotwhereto_number(to_char(sysdate,'yyyy'))-to_number(substr(to_char(t.birthdate,'yyyymmdd'),0,4))>=0andto_number(to_char(sysdate,'yyyy'))-to_number(substr(to_char(t.birthdate,'yyyymmdd')...
oracle数据库中过程编写成功,但是测试时报错ORA-01722
你的birthday这一列的数据类型是否是日期型,如果是的话那么就不能直接使用to_number这种方式来强制类型转换,而应该像你先前那样使用to_char作为过渡。而如果birthday这一列本身就是字符类型的话,那就要看一下这个日期是以何种方式存储的,例如年份是否安排在前4位,是否使用完整的年。以下是我改动后的,你看是否能正确执行:selectcount(t.belongcity)cntfrompolitical_baseinfotwhereto_number(to_char(sysdate,'yyyy'))-to_number(substr(to_char(t.birthdate,'yyyymmdd'),0,4))>=0andto_number(to_char(sysdate,'yyyy'))-to_number(substr(to_char(t.birthdate,'yyyymmdd'),0,4))<=40groupbyt.belongcity;2017-09-19