Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

sql - How do I remove repeated column values from report

FROM THIS:

Hotel                     Type   Room Guest                                     From      To
    ------------------------- ------ ---- ----------------------------------------- --------- ---------
    University Inn & Suites   Double 101  George Brown                              11-SEP-10 14-SEP-10
    University Inn & Suites   Double 101  George Brown                              11-OCT-10 13-OCT-10
    University Inn & Suites   Double 102
    University Inn & Suites   Double 103
    University Inn & Suites   Double 104
    University Inn & Suites   Double 105
    University Inn & Suites   Family 106  George Brooks                             22-SEP-10 27-SEP-10
    University Inn & Suites   Family 107
    University Inn & Suites   Single 201  Sandra Williams                           15-SEP-10 19-SEP-10
    University Inn & Suites   Single 201  Liz Armstrong                             16-SEP-10 18-SEP-10
    University Inn & Suites   Single 201  Craig Harper                              19-SEP-10 22-SEP-10
    University Inn & Suites   Single 202  Roger Harris                              03-SEP-10 10-SEP-10
    University Inn & Suites   Single 202  Tonya Harris                              23-SEP-10 27-SEP-10
    University Inn & Suites   Single 203
    University Inn & Suites   Single 204
    University Inn & Suites   Single 205

TO THIS

    Hotel                     Type   Room Guest                                     From      To
    ------------------------- ------ ---- ----------------------------------------- --------- ---------
    University Inn & Suites   Double 101  George Brown                              11-SEP-10 14-SEP-10
                                          George Brown                              11-OCT-10 13-OCT-10
                                     102  
                                     103
                                     104
                                     105
                              Family 106  George Brooks                             22-SEP-10 27-SEP-10
                                     107
                              Single 201  Sandra Williams                           15-SEP-10 19-SEP-10
                                     201  Liz Armstrong                             16-SEP-10 18-SEP-10
                                          Craig Harper                              19-SEP-10 22-SEP-10
                                     202  Roger Harris                              03-SEP-10 10-SEP-10
                                          Tonya Harris                              23-SEP-10 27-SEP-10
                                     203
                                     204
                                     205
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Is this the structure of the table that you are showing (or) is it the result of a report?

My guess is it is the result of a SQLPLUS report. If that is the case, and you want the Hotel name to appear once (until it changes), you can specify

Break on hotel;

Select hotel, type, room_guest
  from hotels
  order by hotel;

to achieve the desired result.

If it the structure, you cannot delete the column values for all but the first row. (in fact, there is nothing like the first row as far as the database is concerned). If you are trying to eliminate duplicate data, then look into normalizing your table.

http://en.wikipedia.org/wiki/Database_normalization

Please post the table description and the tool (if any) so that you'd get the appropriate answers for your case.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.6k users

...