title: SQL: Getting multiple line entries (from same table) in one line?
body: <p>I already looked the questions that may have my answer, but none really has so:</p>
  
  <p>I have a table like this:</p>
  
  <pre><code>id | timestamp | date       | identifier | personnel_number
  00 | 00000     | 2000-01-01 | A          | 01
  01 | 28800     | 2000-01-01 | B          | 01
  02 | 29000     | 2000-01-01 | A          | 01
  03 | 45000     | 2000-01-01 | B          | 01
  .
  .
  .
  </code></pre>
  
  <p>I need the results (in this case all four of the filled lines) in half the amount of lines (alternating between identifiers A and B). I already tried:</p>
  
  <pre><code>SELECT DISTINCT
       a.timestamp,
       b.timestamp
  FROM table AS a
  LEFT JOIN table AS b
       ON a.personnel_number = b.personnel_number
       AND a.date = b.date
       AND a.identifier != b.identifier
  WHERE a.personnel_number = [SOMEVALUE]
       AND a.date = [SOMEDATE]
       AND a.identifier = "A"
       AND a.id &gt; b.id
       AND a.timestamp &lt; b.timestamp
  GROUP BY a.timestamp, b.timestamp
  ORDER BY a.timestamp ASC
  </code></pre>
  
  <p>But that does not give me the required two lines with<br></p>
  
  <pre><code>a.timestamp#1, b.timestamp#1
  a.timestamp#2, b.timestamp#2
  </code></pre>
  
  <p>but gives me</p>
  
  <pre><code>a.timestamp#1, b.timestamp#1
  a.timestamp#1, b.timestamp#2
  a.timestamp#2, b.timestamp#2
  </code></pre>
  
  <p>I also got it wrong another way by using MIN (false way obviously). Thought it was right because there only were two results.</p>
  
  <pre><code>SELECT DISTINCT
       a.timestamp,
       MIN(b.timestamp)
  FROM table AS a,
       table AS b
  WHERE a.personnel_number=[SOMEVALUE]
       AND b.personnel_number=[SOMEVALUE]
       AND a.date=[SOMEDATE]
       AND b.date=[SOMEDATE]
       AND a.identifier = "A"
       AND b.identifier = "B"
       AND b.id &gt; a.id
  GROUP BY a.timestamp
  ORDER BY a.timestamp ASC
  </code></pre>
  
  <p>My results were like this then, so obviously not correct either^^°</p>
  
  <pre><code>a.timestamp#1, b.timestamp#1
  a.timestamp#2, b.timestamp#1
  </code></pre>
  
  <p>Any idea at all how to get my needed result and of course results like it with more table entries?</p>
  
  <p>Edit: As to answer the question, I use Sybase.</p>