如何从报告中删除重复的列值
从这:
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是您显示的表格结构(还是)报告的结果?
我的猜测是它是 SQLPLUS 报告的结果。如果是这种情况,并且您希望酒店名称出现一次(直到其更改),您可以指定
以达到所需的结果。
如果是结构,则无法删除除第一行之外的所有列值。 (事实上,就数据库而言,没有什么比第一行更好的了)。如果您想消除重复数据,请考虑规范化您的表。
http://en.wikipedia.org/wiki/Database_normalization\
请发布表说明和工具(如果有),以便您获得适合您案例的答案。
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
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.
使用
lag
访问前一行并检查它是否与当前行具有相同的值怎么样?How about using
lag
to access the previous row and check if it has the same value as the current one?