chalie001
asked on
null value
hi i have this sqql select empno,hire_date from employee where hire_date is null am geting 0 rows bust when i do select * from employee i can see empty value in hire_date column
hire_date date datatype
hire_date date datatype
you are seeing that issue in sql*plus or toad or any other app/tool ?
Try 1
Try 2
Try 3
--
select empno,hire_date from employee where hire_date is null OR hire_date = ''
--
Try 2
--
select empno,hire_date from employee where LENGTH(hire_date) = 0
--
Try 3
--
select empno,hire_date from employee where hire_date = ''
--
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@Geert
What do 2 lines "from dual" achieve?
What do 2 lines "from dual" achieve?
with employee as
(select 1 empno, cast(' ' as varchar2(50)) hire_date from dual
union all
select 2 empno, to_char(sysdate) hire_date from dual
)
select empno,hire_date, dump(hire_date) from employee
===============================================================
EMPNO HIRE_DATE DUMP(HIRE_DATE)
1 Typ=1 Len=2: 32,32
2 04.11.16 Typ=1 Len=8: 48,52,46,49,49,46,49,54
===============================================================
Paul,
Really ?
You have never been on a database where there is no employee table ?
you have never had to conjure up some sample rows to explain something using "from dual" ?
And you got to level 47 how exactly ?
Really ?
You have never been on a database where there is no employee table ?
you have never had to conjure up some sample rows to explain something using "from dual" ?
And you got to level 47 how exactly ?
ASKER
i use is null
sorry... It was a serious question
I just don't follow the logic as you haven't unioned the table employee at all, you just have 2 rows from dual
did you intend to union to the table?
forgive me I was attempting to help
I just don't follow the logic as you haven't unioned the table employee at all, you just have 2 rows from dual
did you intend to union to the table?
forgive me I was attempting to help
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This is working for me .. :)
Output...
-------------------------- --------
EMPNO HIRE_DATE
1 1
with employee as
(select 1 empno, cast(' ' as varchar2(50)) hire_date from dual
union all select 2 empno, to_char(sysdate) hire_date from dual)
select empno,hire_date
from employee
WHERE hire_date = ' '
Output...
--------------------------
EMPNO HIRE_DATE
1 1
That has a space in it, it is not an empty string. What was posted earlier is:
hire_date = ''
No space, so it is an empty string.
hire_date = ''
No space, so it is an empty string.
Paul,
i can't union the employee table, as i don't have a database here with an employee table
i don't have access to chalie001's database, i think
> you never one when a new user with a certain alias is asking question on a site and actually sitting next to you
chalie001,
how come paul get's point by using my sample, but i don't ?
i can't union the employee table, as i don't have a database here with an employee table
i don't have access to chalie001's database, i think
> you never one when a new user with a certain alias is asking question on a site and actually sitting next to you
chalie001,
how come paul get's point by using my sample, but i don't ?
Geert, thanks. i understand now. I didnt befote.
chalie001
I am not comfortable having points for asking a question
chalie001
I am not comfortable having points for asking a question
Can you provide the output of this in excel or screenshot ?