小编典典

如何从报告中删除重复的列值

sql

由此:

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

对此

    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

阅读 171

收藏
2021-03-17

共1个答案

小编典典

这是您要显示(或)的表的结构,还是报告的结果?

我的猜测是它是SQLPLUS报告的结果。如果是这种情况,并且您希望酒店名称出现一次(直到更改),则可以指定

Break on hotel;

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

以达到预期的结果。

如果是结构,则无法删除除第一行以外的所有列的值。(实际上,就数据库而言,没有像第一行这样的东西)。如果您要消除重复的数据,请考虑对表进行规范化。

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

请发布表格说明和工具(如果有),以便为您的案件找到合适的答案。

2021-03-17