Home » SQL & PL/SQL » SQL & PL/SQL » Recent Joining records
Recent Joining records [message #232704] Mon, 23 April 2007 01:24 Go to next message
akkumar81
Messages: 144
Registered: February 2007
Location: india
Senior Member



Hi,

I want recent joining employee records in department wise in a table.

pls help ..

Arunkumar Laughing
Re: Recent Joining records [message #232707 is a reply to message #232704] Mon, 23 April 2007 01:26 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
You want a lot in a short amount of time. Why don't you fire up SQL*plus and get started?

MHE
Re: Recent Joining records [message #232714 is a reply to message #232707] Mon, 23 April 2007 01:30 Go to previous messageGo to next message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

http://www.orafaq.com/forum/t/59966/91729/
Re: Recent Joining records [message #232717 is a reply to message #232714] Mon, 23 April 2007 01:33 Go to previous messageGo to next message
ammishra
Messages: 179
Registered: January 2007
Location: india
Senior Member
SELECT d.deptno
     , d.hdate
     , e.ename
FROM   (SELECT   deptno
               , MIN (hiredate) hdate
        FROM     emp
        WHERE    deptno IS NOT NULL
        GROUP BY deptno
        ORDER BY deptno) d
     , emp e
WHERE  d.deptno = e.deptno AND d.hdate = e.hiredate



--yash

[Updated on: Mon, 23 April 2007 01:41] by Moderator

Report message to a moderator

Re: Recent Joining records [message #232721 is a reply to message #232717] Mon, 23 April 2007 01:51 Go to previous messageGo to next message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Yash,

If it is "recent" I think you should use MAX instead of MIN.

In addition, I think you should study analytic functions, especially dense_rank in this case.
Your query is how we do things in Oracle7 and is not the right way to do it now (unless you use 10g and have an index on hiredate).

Regards
Michel
Re: Recent Joining records [message #232752 is a reply to message #232721] Mon, 23 April 2007 03:22 Go to previous message
ammishra
Messages: 179
Registered: January 2007
Location: india
Senior Member
Thx Michel !! it would be always great if you correct me when ever i am wrong ....i am novice in oracle ..That is true I am not that much aware of new style (feature) of query writing..
So I insist all of you please replay all the query either they are very simple and easy ..
I know that you guys will write query in different manner over new feature of oracle…so we will lean some thing new always to this forum through expert guys like you ….

Thanks,
--Yash


Previous Topic: selecting 2nd largest salary
Next Topic: like function
Goto Forum:
  


Current Time: Tue Dec 06 12:33:55 CST 2016

Total time taken to generate the page: 0.16171 seconds