1

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 

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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 ... 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.