Home » RDBMS Server » Server Administration » Self join
Self join [message #374981] Tue, 17 July 2001 04:32 Go to next message
Jaya Kumar NM
Messages: 11
Registered: August 2000
Junior Member
I have a data like this
empno sal date
100 2000 10-jul-01
100 3000 12-jul-01
200 1000 10-jul-01
200 1000 14-jul-01
300 2000 10-jul-01
300 3000 12-jul-01
300 3000 14-jul-01

The output I want is
empno sal date
100 3000 12-jul-01

I want to compare only the last two rows for each employee(i.e max and second max date), if the salary is not matching the max(date) row should be displayed.
Thanks
Re: Self join [message #374982 is a reply to message #374981] Tue, 17 July 2001 06:36 Go to previous message
murarishettysrinivas
Messages: 9
Registered: July 2001
Junior Member
try this
select empno,max(sal),max(date) from table
group by empno
Previous Topic: Re: Altering Table
Next Topic: Difference betn. SQL & SQL *Plus
Goto Forum:
  


Current Time: Wed Jul 03 03:32:34 CDT 2024