Home » SQL & PL/SQL » SQL & PL/SQL » ORA-00932: inconsistent datatypes: expected NUMBER got - (11g,11.1.0.6.0,window7)
ORA-00932: inconsistent datatypes: expected NUMBER got - [message #604087] Mon, 23 December 2013 23:33 Go to next message
vinaykumarora
Messages: 1
Registered: December 2013
Location: HYDERABAD
Junior Member
1 SELECT ENAME,JOB,SAL EMPSAL,
2 CONNECT_BY_ROOT(SAL) BOSSSAL,
3 CONNECT_BY_ROOT(SAL)-SAL DIFF
4 FROM EMP
5 START WITH ENAME='KING'
6* CONNECT BY PRIOR EMPNO=MGR
SQL> /
Re: ORA-00932: inconsistent datatypes: expected NUMBER got - [message #604100 is a reply to message #604087] Tue, 24 December 2013 00:48 Go to previous message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Here's one way to do that:
SQL> WITH test AS (    SELECT ename,
  2                           job,
  3                           sal empsal,
  4                           CONNECT_BY_ROOT (sal) bossal
  5                      FROM emp
  6                START WITH ename = 'KING'
  7                CONNECT BY PRIOR empno = mgr)
  8  SELECT ename,
  9         job,
 10         empsal,
 11         bossal,
 12         bossal - empsal diff
 13    FROM test;

ENAME      JOB           EMPSAL     BOSSAL       DIFF
---------- --------- ---------- ---------- ----------
KING       PRESIDENT       5800       5800          0
JONES      MANAGER         3775       5800       2025
SCOTT      ANALYST         3800       5800       2000
ADAMS      CLERK           1900       5800       3900
FORD       ANALYST         3800       5800       2000
SMITH      CLERK           1600       5800       4200
BLAKE      MANAGER         3650       5800       2150
ALLEN      SALESMAN        2400       5800       3400
WARD       SALESMAN        2050       5800       3750
MARTIN     SALESMAN        2050       5800       3750
TURNER     SALESMAN        2300       5800       3500
JAMES      CLERK           1750       5800       4050
CLARK      MANAGER         3250       5800       2550
MILLER     CLERK           2100       5800       3700

14 rows selected.

SQL>
Previous Topic: Delete primary key in case of parent-child relation
Next Topic: How to restrict the rows while generating XML
Goto Forum:
  


Current Time: Fri Apr 26 08:20:15 CDT 2024