Link to home
Start Free TrialLog in
Avatar of Enrique Gomez Esteban
Enrique Gomez Esteban

asked on

ORACLE INNER JOIN

Hi
Can I use a WHERE clause to limit the sql process? I means:


select  empno, ename
from emp p1
where deptno not = 12
inner join
(select empno, max(empno)
from emp p2
group by empno) grouemp
ON  p1.empno= gouemp.empno
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what do you mean by >>  to limit the sql process ?
Hi You can do like this

select  empno, ename
from (select * from emp where deptno != 12)  p1

inner join
(select empno, max(empno)
from emp p2
group by empno) grouemp
ON  p1.empno= gouemp.empno
mmm

but the subquery makes very little sense.

if you group by empno, then max(empno) is the same value

table emp
empno
----------
1
2
3

      SELECT
            empno
          , MAX(empno)
      FROM emp p2
      GROUP BY empno

empno max(empno)
----------  -----------------
1            1
2            2
3            3
4            4

so, it does not achieve much

Can you provide these?
a. "sample data"
b. "expected result"

then we can suggest a query for you
<>  "NOT EQUAL"

12 <> 13
'a' <> 'fred'

You can also use this syntax

!=

12 != 13
'a' != 'fred'

<> is available in all SQL variants,
!= is only for some vendors
Avatar of Enrique Gomez Esteban
Enrique Gomez Esteban

ASKER

I've requested that this question be deleted for the following reason:

The response was good, anyway.
pls give a valid reason to delete this question
that is not a valid reason
@Enrique Gomez Esteban,

can you elaborate further, or post your solution here (if there is any), or as mentioned, pls provide reason to close this question.
Thank for your recommendations. I could not check it properly.
@Enrique Gomez Esteban,

You should not just choose any comment at random, ID: 41001026 does not offer a solution to your original question.

If your problem was solved by expert comments BEFORE ID: 41001025 then you should choose one or more of those comments.
Agreed with Paul on the principle of accepting a comment as the answer. Am already put a comment earlier in the "request an attention" relating to this issue.
Sorry for any incovenience.  I opened this question and I got several helpful anwers but I could not check it properly at the moment so the question remains opened several months. I just was trying to close it. Thanks for your support.
Well,
I think I have already explained that that the question was not enough detailed and of course the answer  also lack of this detail. As it was my fault because this  issue that was very specifi c was removed from the backlog  I could not give the right detail.  Thats is why I tried to DELETE the question  (sure I did something wrong) and  I insist on the question unfortunately was not detailed properly and of course the answer  is not detailed enough or is not addressing the right question and documentation.
That's is whiy I think a grade=B is right.