Solved

Job <> Manager or Clerk Has Null in Comm

Posted on 2008-10-15
8
310 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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 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 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 eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Suggested Solutions

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
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.

751 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