Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Job <> Manager or Clerk Has Null in Comm

Posted on 2008-10-15
8
Medium Priority
?
313 Views
Last Modified: 2013-12-19
Hi,

I want to find emp job ain't manager or clerk.

!=, still doesn't work.

Does null in Comm reflect output? Should Null include SQL?

select empno, ename, deptno, job
from emp
where (job <> 'manager' OR job <> 'clerk')
and deptno = 10;

===========================
/* Table */

EMPNO ENAME      JOB             MGR HIREDATE          SAL       COMM
---------- ---------- --------- ---------- --------- ---------- ----------
    DEPTNO

7698 BLAKE      MANAGER            7839 01-MAY-81         2850
      30

7782 CLARK      MANAGER            7839 09-JUN-81         2450
       10

7900 JAMES      CLERK            7698 03-DEC-81                 950
      30

 7934 MILLER     CLERK            7782 23-JAN-82         1300
      10

========================

Output

 EMPNO ENAME        DEPTNO JOB
---------- ---------- ---------- ---------
      7839 KING             10 PRESIDENT
      7782 CLARK            10 MANAGER
      7934 MILLER            10 CLERK



0
Comment
Question by:suredazzle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 22723872
that's because of the condition  you need AND not OR

any job will either be MANGER or CLERK or neither.

So, every job is <> MANGER or <> CLERK or both.

try this...


select empno, ename, deptno, job
from emp
where job <> 'manager'
AND job <> 'clerk'
and deptno = 10;
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 22723874
you can use !=  instead of <> if you want to
0
 
LVL 1

Author Comment

by:suredazzle
ID: 22724041
Hi Sdstuber,

Tried both ways, still not working.

SQL> select empno, ename, deptno, job
from emp
where job != 'manager'
and job != 'clerk'
and deptno = 10;  2    3    4    5  

     EMPNO ENAME        DEPTNO JOB
---------- ---------- ---------- ---------
      7839 KING             10 PRESIDENT
      7782 CLARK            10 MANAGER
      7934 MILLER            10 CLERK

Not too familiar with Null, it shoud be "Not equal". Right?

Let me see what I find on NULL.

0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 74

Expert Comment

by:sdstuber
ID: 22724127
you don't have any nulls though.  if you do care about null then use "IS NULL" or "IS NOT NULL"

in this case you also have case sensitivity, sorry I didn't notice that earlier

clerk != CLERK
manager != MANAGER


SELECT empno, ename, deptno, JOB
FROM emp
WHERE JOB != 'MANAGER'
AND JOB != 'CLERK'
AND deptno = 10;


you could also use not in

SELECT empno, ename, deptno, JOB
FROM emp
WHERE JOB not in ('MANAGER','CLERK')
AND deptno = 10;

0
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 22724144
if you want to include NULL's (there aren't any in the scott.emp table though)

it might look like this...


SELECT empno, ename, deptno, JOB
FROM emp
WHERE (JOB not in ('MANAGER','CLERK') or job is null)
AND deptno = 10;
0
 
LVL 1

Author Closing Comment

by:suredazzle
ID: 31506421
Hi Sdstuber,

I used your solution. It works! Thanks very much.

Gosh, it is case sensitive.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 22724299
glad I could help
0
 
LVL 1

Author Comment

by:suredazzle
ID: 22724312
Hi Sdstuber,

I used your solution. It works! Thanks very much. I learn a lot.

Gosh, it is case sensitive.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question