简体   繁体   English

如何在Oracle中使用投影条件作为月份名称从表中提取元组?

[英]How to extract tuples from a table using the projection criteria as month name in oracle?

I have a table 'emp' whose schema is defined as(empno, ename,hiredate) ,I am trying to project out the names of all those employees who joined in the moth of January , so for this I wrote the below query but it not printing any records ,It works fine if I don't use the where clause , else it is not working . 我有一个表'emp',其表模式定义为(empno,ename,hiredate),我试图投影出所有在一月份加入的员工的姓名,为此,我编写了以下查询,但它不打印任何记录,如果我不使用where子句,它将正常工作,否则它将不起作用。

select ename from emp where ( to_char(to_date(extract(month from hiredate),'MM'),'MONTH')) like 'JANUARY'​

Please guide me where I am making mistake . 请指导我哪里出错了。

It is unnecessarily too complicated. 它不必要地太复杂了。

Try to run this select: 尝试运行此选择:

select hiredate,extract(month from hiredate) from emp 

Then if January is 1 from this select and there arent any mistakes, you can use: 然后,如果此选择的一月为1,并且没有任何错误,则可以使用:

select ename from emp where extract(month from hiredate)=1

Try this: 尝试这个:

select ename from emp where ( to_char(to_date(extract(month from hiredate),'MONTH'),'MONTH')) like 'JANUARY'​ 从emp中选择ename,其中(to_char(to_date(提取(从雇用日期起的月份),'MONTH'),'MONTH'))像'JANUARY'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM