Home » SQL & PL/SQL » SQL & PL/SQL » help in SQL query to find the required row (oracle 10g)
help in SQL query to find the required row [message #352652] Wed, 08 October 2008 16:48 Go to next message
mjhraja
Messages: 1
Registered: October 2008
Junior Member
Hello All,

Please help me to get the following query

I have a req like this ..

employee is moved between departments and updated date is available in the table for the transactions.

I need to take the current dept_id min record but that should be greater than the old_dept id maximum updated date.

here employee is moved from 10->20->10->again 20.

example records

EMP_NO, DEPT _ID ,updated_date

100 10 01-oct-08

100 10 01-oct-08

100 20 02-oct-08

100 10 03-oct-08

100 20 03-oct-08

100 20 05-oct-08


In this case I need the following record

100 20 03-oct-08

and not the record
100 20 02-oct-08
as employee is moved to dept_id 10 after that .

Thanks in advance,
Raja.


Re: help in SQL query to find the required row [message #352687 is a reply to message #352652] Thu, 09 October 2008 00:46 Go to previous message
Michel Cadot
Messages: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
What did you already try to achieve this?

Also please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.

Post a test case: create table and insert statements along with the result you want with these data.

Regards
Michel
Previous Topic: Updating a varchar2 field
Next Topic: Round values in a table
Goto Forum:
  


Current Time: Thu Feb 13 11:10:40 CST 2025