2

I have this problem and I have no idea how to solve it:

RegNo                  Date                       Notes
5                    2014-01-01                 team checking
5                    2014-01-01                 add telephone no
5                    2014-01-01                 ben 14708
6                    2014-01-15                 contact by tel                    
6                    2014-01-15                 updating name 
7                    2014-02-08                 other checkings

I need to return:

RegNo              Date                Notes1                    Notes2              Notes3
5                 2014-01-01           team checking         add telephone no      ben 14708
6                 2014-01-15           contact by tel        updating name             
7                 2014-02-08           other checkings

Any idea would be helpful.

Taryn
  • 242,637
  • 56
  • 362
  • 405
user3253051
  • 95
  • 1
  • 1
  • 5
  • 1
    Do you *have* to do this in the database? My vote is usually to handle this kind of display-formatting stuff in the presentation layer. – lc. Feb 17 '14 at 16:11
  • Are you ok with creating another table in your database that is formatted like your second example? If so, you can get creative with a `SELECT INTO` and a few `case` statements – tkendrick20 Feb 17 '14 at 16:17
  • What is missing from the table is a sequence-no that tells in which order the lines within the same RegNo appear. Note that no "natural" row order is given with SQL. You always need to order by some column if you want a defined order. – Olivier Jacot-Descombes Feb 17 '14 at 16:19

0 Answers0