Consecutive rows
Posted by:
TecZ --
Date: August 29, 2008 09:51AM
Hello,
Im know mysql has great capabilities but I dont really know how to use the potential.
I'll explain what I'm trying to do.
I have a table like this:
| date | time | size | amount |
| 2008-03-03 | 23:00:00 | 40 | 2 |
| 2008-03-03 | 23:00:00 | 40 | 2 |
| 2008-03-03 | 23:00:00 | 40 | 1 |
| 2008-03-03 | 23:00:00 | 40 | 2 |
| 2008-03-03 | 23:00:00 | 40 | 2 |
| 2008-03-03 | 23:00:00 | 80 | 2 |
| 2008-03-03 | 23:00:00 | 40 | 2 |
| 2008-03-03 | 23:00:00 | 40 | 2 |
| 2008-03-03 | 23:00:01 | 40 | 1 |
| 2008-03-03 | 23:00:01 | 40 | 1 |
And I need the result to be like this:
| date | time | size | amount |
| 2008-03-03 | 23:00:00 | 40 | 2 |
| 2008-03-03 | 23:00:00 | 40 | 1 |
| 2008-03-03 | 23:00:00 | 40 | 2 |
| 2008-03-03 | 23:00:00 | 80 | 2 |
| 2008-03-03 | 23:00:00 | 40 | 2 |
| 2008-03-03 | 23:00:01 | 40 | 1 |
It is like removing duplicate rows but slightly different. I need effectively to eliminate consecutive duplicated rows (instead of all the duplicated).
In php or other language what can be done is navigate to the next row and check if it is different from the first or not. If it is keep it, otherwise remove it.
I know how to do it using other languages but I'm pretty sure it is possible to do it just with an SQL query.
Thanks in advance,
Ricardo
Subject
Written By
Posted
Consecutive rows
August 29, 2008 09:51AM
September 01, 2008 01:23AM
September 01, 2008 01:40AM
September 01, 2008 03:23AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.