title: SQL First and Last Occurrences - Group By forcing me to group everything in select
body: <p>Table1</p>
  
  <pre><code>EmployeeID | StartDateTimestamp | CohortID | CohortName
  ---------- | ------------------ | -------- | ----------
  1          | 20080101 01:30:00  | 1        | Peanut
  1          | 20090204 01:01:00  | 2        | Apple
  2          | 20190107 05:52:14  | 1        | Peanut
  3          | 20190311 02:35:26  | 2        | Apple
  </code></pre>
  
  <p>Employee</p>
  
  <pre><code>EmployeeID | HireStartName | StartDateTimestamp2
  ---------- | ------------- | -------------------
  1          | HiredStart    | 20080501 01:30:00
  1          | DeferredStart | 20090604 01:01:00
  2          | HiredStart    | 20190115 05:52:14
  3          | HiredStart    | 20190330 02:35:26
  </code></pre>
  
  <p>Learning on the go. My query below will list out all the EmployeeID's and not just the first Cohort ID and last Cohort ID. Group by forces me to group StartDateTimestamp2 with employeeid and it still lists all employee ID's, and does not look like intended result below.</p>
  
  <p>Ideally, the (first occurrences) result should be:</p>
  
  <pre><code>CohortID | StartDateTimestamp2
  -------- | -------------------
  1        | 20080501 01:30:00
  2        | 20190115 05:52:14
  </code></pre>
  
  <p>My Query Below</p>
  
  <pre><code>SELECT firsttable.Cohortid,
         employeetable.StartDateTimestamp2
  FROM   Table1 firsttable
  INNER JOIN Employee employeetable ON employeetable.employeeid = firsttable.employeeid
  </code></pre>
  
  <p>The actual question:
  Use first instance of CohortName to determine the start date of each cohort</p>
  
  <p>Result:</p>
  
  <pre><code>Cohort ID | StartDateTimesstamp2
  </code></pre>