SQL Server 2008 : SELECT min(date) -


i'm trying simple select statement i'm having hard time doing it.

i have table these columns:

companyid, companydept, dateadded 

i'm trying select statement this...

select companyid, companydept  min(dateadded) 

so there multiple dates dateadded - i'm trying select companydept , companyid earliest dateadded.

edit: select companyid, companydept dateadded=min because there might 3 or more dates such 10/1/2015, 11/12/2015, 1/4/2016 -(rows of data mean) i'm trying select date looking @ earliest possible date (10/1/2016)

you can try getting first record using top 1 , ordering date.

select top 1     companyid, companydept      table order      dateadded 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -