English 中文(简体)
甲骨文——如何从一个雇用栏的一周日表中输出数据?
原标题:Oracle SQL - How do i output data from a table based on the day of the week from a hiredate column?

具体如下: 我的表格有第6栏,其中一栏为Hiredate。 年限 现在,我只想输出一下星期一或星期二聘用的数据。

目前,我正试图按照以下方针做一些事情:

SELECT name, position, hiredate
FROM table
WHERE hiredate =  monday ;

SELECT TO_CHAR(hiredate,  day ) 
FROM table
WHERE TO_CHAR(hiredate,  day ) =  monday ;

这两项工作都没有,我所尝试的其他结构也没有任何变化。

I m fairly certain this is extremely simple, but I am a beginner and am kind of lost on where to go. Any help 或tips would be appreciated.

最佳回答

Hoons的回答是正确的,但只有在贵国的Oracle会议使用英语(NLS_LANGUAGE)的情况下才会奏效。

Another query that work for all languages is

select name, position, hiredate
 from table
where to_char(sysdate,  D ) in (1, 2); -- 1 monday; 2 tuesday

http://www.ohchr.org。

1 monday
2 tuesday
3 wednesday
4 thrusday
5 friday
6 saturday
7 sunday
问题回答

In general, I have found Oracle s own 10g docs invaluable, you can find them here: Oracle 10g Doc Homepage, and in this case searching for day of week yields some good results, like this one: enter link description here, on that page, I see: DAY Yes Name of day, padded with blanks to display width of the widest name of day in the date language used for this element.

So I m thinking that you re probably getting back Monday, but padded with spaces afterwards. I would probably try to get the abbreviated form, something like:

SELECT TO_CHAR(hiredate,  DY ) FROM table WHERE lower(TO_CHAR(hiredate,  DY )) in ( mon ,  tue );




相关问题
what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签