Home » RDBMS Server » Server Administration » A help!
A help! [message #372932] Mon, 19 March 2001 05:54 Go to next message
Gayathri
Messages: 19
Registered: February 2001
Junior Member
Hi,
A query!
i'm new to oracle.

Actually in our familiar emp table i have inserted some more values and now i want to get some rows selected in the fashion i queried.
the values in the table are:
SQL> select * from emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
--------- ---------- --------- --------- --------- --------- --------- ---------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
7369 gayathri faculty 7860 23-DEC-80 1300 0 30
7492 selva analyst 7805 12-JAN-00 4000 0 20

16 rows selected.

my query is:
SQL> select * from emp
2 where hiredate>'12-jan-83';

no rows selected

but there is a row available. It should get selected.
First, i thought the value i entered might have been taken as '1900' instead of '2000'. so, i checked that with the query given below.

SQL> select to_char(hiredate,'dd-mon-yyyy') from emp
2 where ename='selva';

TO_CHAR(HIR
-----------
12-jan-2000

then why it is not getting selected?
how should i have to do?

pl. help me.

Thanx in adv.

Gayathri
Re: A help! [message #372933 is a reply to message #372932] Mon, 19 March 2001 07:53 Go to previous message
Bala
Messages: 205
Registered: November 1999
Senior Member
Hi,

Its not the hire date, its the date you have given in your qry 12-jan-83-----83 is being taken as 2083.....
your-hiredate is not greater than 12-jan-2083

see
BINTEST> select to_char(to_date('12-jan-83', 'dd-mon-yy'), 'dd-mon-yyyy') from dual

TO_CHAR(TO_
-----------
12-jan-2083
...

So try
select * from emp where hiredate > to_date('12-jan-1983', 'dd-mon-yyyy');

Bala.
Previous Topic: sql query help please!!
Next Topic: Re: SQL
Goto Forum:
  


Current Time: Sat Jun 29 00:34:00 CDT 2024