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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Distinct row from the table.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-05 : 10:57:52
RameshBabu writes "I have a table with column EMPNO and EMPDATE and I have the following data :

Empno EmpDate
1 12/12/2001
1 14/12/2001
2 17/05/2001
3 18/05/2002

I want the following output with the recent empdate and the empno should be distinct .Can any one send me a query for this:


Empno EmpDate

1 14/12/2001
2 17/05/2001
3 18/05/2002

Thanking you in advance.."

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-05 : 11:13:46
GROUP BY GROUP BY GROUP BY....

select
Empno,
max(EmpDate) as MaxEmpDate
from
PsuedoDDLTable
group by
EmpNo

 


<O>
Go to Top of Page

joshb
Yak Posting Veteran

52 Posts

Posted - 2002-07-05 : 11:14:25
Try something like this:

SELECT EmpNo, MAX(EmpDate)
FROM Employes
GROUP BY EmpNo

Go to Top of Page
   

- Advertisement -