Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
santhoshcool123
Starting Member
4 Posts |
Posted - 2012-03-20 : 07:00:09
|
| Hi all, I am basically new to SQL language, I am having a small doubt on how to solve this queryThe table isEMP(Empno PK, empname, sal, hiredate, comm, deptno, job, mgr)I want to list the employees who are working in the same job as that of Blake, but need to exclude blake..I got to the first step i.e. select ename from emp where job in (select job from emp where ename='blake'); but from here i don't know how to exclude blake from this.Advanced Thanks for the help |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-03-20 : 07:07:22
|
You can add another condition to your where clause as:AND ename <> 'blake' |
 |
|
|
santhoshcool123
Starting Member
4 Posts |
Posted - 2012-03-20 : 07:10:53
|
| SQL> select ename from emp where job in (select job from emp where ename='BLAKE' and ename<>'BLAKE');no rows updatedI got this as an output for it, but there are 2 more employees who are working other than blake |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-03-20 : 07:13:16
|
Sorry, I should have been more clear. What I meant was:select ename from emp where job in (select job from emp where ename='BLAKE') and ename<>'BLAKE'; |
 |
|
|
santhoshcool123
Starting Member
4 Posts |
Posted - 2012-03-20 : 07:15:08
|
| Thanks very much |
 |
|
|
|
|
|