1 Reply Latest reply on Mar 18, 2009 12:23 PM by Newsgroup_User

    Table separator after database query

    Lumpia
      I'm looking for a way to insert a table separator/line break after an output from SQL Server based on last name or shift. For example, here's a basic table output, showing the manager, their employee, and the shift they work:

      MGR | EMPLOYEE | SHIFT
      Smith, John | Anderson, Thomas | 1st
      Smith, John | Jackson, Randy | 1st
      Miller, Tammy | Cowell, Simon | 2nd
      Johnson, Johnny | Abdul, Paula | 1st
      Smith, John | Marshall, Sarah | 3rd
      Miller, Tammy | Rabbit, Peter | 3rd

      The users want to be able to sort by the managers last name, with a separator after each manager like so:

      MGR | EMPLOYEE | SHIFT
      Johnson, Johnny | Abdul, Paula | 1st
      ----------------------------------------------------------
      Smith, John | Anderson, Thomas | 1st
      Smith, John | Jackson, Randy | 1st
      ----------------------------------------------------------
      Miller, Tammy | Cowell, Simon | 2nd
      Miller, Tammy | Rabbit, Peter | 3rd
      Smith, John | Marshall, Sarah | 3rd

      If this were sorting by shift, I could do this manually with a select statement:

      SELECT mgr, employee, shift
      FROM some_database
      WHERE (shift = 1)
      ORDER BY mgr

      and then put in table code with a separator like so:

      <tr><td colspan="3" bgcolor="#990000" height="2"></td></tr>

      but still, I'd have to do this for each shift with another WHERE (shift=2), etc. So this is sort of a 2 part question.

      1) How to output data from database with a separator after the mgr last name and
      2) If I were to sort by shift, how could I create a loop where I don't have to use WHERE (shift=1), (shift=2), etc, and then a separator is put in after each shift.

      Thanks.