I need to get the earliest Created Date with group by identity number. Here the sample of record.
| AccountID | DisplayName | CreatedDate | IdentityNumber | OrganizationID | |-----------|---------------|-------------|----------------|----------------| | 1 | John | 1 Jan 2018 | 1234 | 1000 | | 2 | John | 15 Jan 2018 | 1234 | 1001 | | 3 | John | 20 Jan 2018 | 1234 | 1002 | | 4 | Michael | 1 Jan 2018 | 1235 | 1000 | | 5 | Michael | 3 Jan 2018 | 1235 | 1003 | | 6 | Wood | 2 Jan 2018 | 1236 | 1002 | So I want to produce the result like this.
| AccountID | DisplayName | CreatedDate | IdentityNumber | OrganizationID | |-----------|---------------|-------------|----------------|----------------| | 1 | John | 1 Jan 2018 | 1234 | 1000 | | 4 | Michael | 1 Jan 2018 | 1235 | 1000 | | 6 | Wood | 2 Jan 2018 | 1236 | 1002 | This my sql snippet
SELECT IdentityNumber, MIN(CreatedDate) FROM Accounts GROUP BY IdentityNumber And yes I can get the earliest record with group by identity number. But how I can grab the AccountID, DisplayName, OrganizationID without group by?