How do I remove repeated column values from report

后端 未结 2 448
予麋鹿
予麋鹿 2020-12-21 23:37

FROM THIS:

Hotel                     Type   Room Guest                                     From      To
    ------------------------- ------ ---- ----------         


        
相关标签:
2条回答
  • 2020-12-22 00:09

    How about using lag to access the previous row and check if it has the same value as the current one?

    select decode(hotel,
                  lag(hotel, 1, null) over (order by hotel, room, ...), null,
                  hotel) as "Hotel"
      from ...
    
    0 讨论(0)
  • 2020-12-22 00:17

    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.

    0 讨论(0)
提交回复
热议问题