jasmeet
jasmeet

Reputation: 105

GROUPING DATEs in sql

i have a table in which there are ids and resigning dates. a singlle id have more than one resigning date.

how can i display the table in which one id have only one resigning date which is the latest ie the maximum date.

can somebody help me plzz....thanx a ton

Upvotes: 0

Views: 118

Answers (1)

p.campbell
p.campbell

Reputation: 100567

select id, max(resignDate)
from mytable
group by id

It's not clear from the question on whether you want to ensure there is only one row in the table for a given ID. If you require that there's only one entry for the given ID, then the statement should have, at the end: having count(id) = 1

Upvotes: 5

Related Questions