Solved

Job <> Manager or Clerk Has Null in Comm

Posted on 2008-10-15
8
305 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
  • 5
  • 3
8 Comments
 
LVL 73

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 73

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
 
LVL 73

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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 73

Accepted Solution

by:
sdstuber earned 500 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 73

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now