Solved

Job <> Manager or Clerk Has Null in Comm

Posted on 2008-10-15
8
307 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
grouping on time windows 6 51
kill process lock Sql server 9 54
Oracle Query - Return results based on minimum value 8 32
convert null in sql server 12 34
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…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

777 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