This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / 请教一个oracle sql 的菜鸟问题 (sysdate-hiredate)/30得到的是月份 但是不是很准确的 怎么能得到精确的月份呢?plus 1. Exclude people hired in September and October of any year.
2.Include both date and time in the hire date format.
这2句话 为什么不能写成where hiredate not in( '%SEP%' , '%OCT%' ) and job in( 'S%' ,'M%') 而只能写成 where hiredate not like '%SEP%' and hiredate not like '%OCT%' and job like 'S%' or job like 'M%'
-menmen(menmen);
2008-10-12
{347}
(#4761510@0)
-
用MONTHS_BETWEEN(SYSDATE, HIREDATE)这2句话 为什么不能写成where hiredate not in( '%SEP%' , '%OCT%' ) and job in( 'S%' ,'M%') 而只能写成 where hiredate not like '%SEP%' and hiredate not like '%OCT%' and job like 'S%' or job like 'M%'
因为%通配符一定要和LIKE连用,IN里面必须严格匹配。
你的写法也有问题,HIREDATE是日期型的话,必须显式转成字符串,否则就可能出现格式问题。
OR的优先级低于AND,要用括号。
where TO_CHAR(hiredate,'MON') NOT IN ( 'SEP', 'OCT') and (job like 'S%' or job like 'M%')
-newkid(newkid);
2008-10-13
{483}
(#4762772@0)