Keshin
Keshin

Reputation: 29

Select Distinct For This Data

can anyone help me ? I want to select distinct with this data :

Code      Name  Description  Date
17-0001   A     01-AOE       02/01/2017
17-0001   A     02-AOE       02/02/2017
17-0001   B     01-AOE       02/01/2017  
17-0001   B     02-AOE       02/03/2017 
etc ...

I Want select distinct the result will be like this :

Code     Name    Date
17-0001  A       02/01/2017  ---> Only The First Date And Not Show The Fld Desc
17-0001  B       02/01/2017
etc ...

Thank's For who's answer my question.

Upvotes: 0

Views: 35

Answers (2)

Mr. Bhosale
Mr. Bhosale

Reputation: 3106

Check this.

select code, name, min(date) as date
from tablename
group by code, name;

Upvotes: 0

Gurwinder Singh
Gurwinder Singh

Reputation: 39477

If I understand correctly, you need a group by and min on the date column

select code, name, min(date)
from t
group by code, name;

Upvotes: 3

Related Questions