title: SELECT records base on previous records contents (no relationship)
body: <p>I have a table, Events, that has an EventId (PK), Date, EmployeeId (FK), and StatusId (FK).</p>
  
  <p>I need to select a record based on criteria of the record that happened directly before it (chronologically by date) for a particular employee. I have no idea how to do this since there isn't a relationship. </p>
  
  <p>I'd like to select a count of all Events, grouped by EmployeeId, where:</p>
  
  <p>(a) StatusId = 1<br />
  (b) The last event by that EmployeeId (chronologically) has a StatusId of 9.</p>
  
  <p>Note that the preceding record for any event is not necessarily related to that employee.</p>
  
  <p>*edited to note that I am using SQL Server, and that I am referencing the previous event chronologically by date!</p>