erw2 <[EMAIL PROTECTED]> wrote:
I have a table with a following data:
Id Text1 Text2 Text3 Text4
-----------------------------------
1 1001 11 test03 test13
2 1002 11 test01 test11
3 1003 12 test04 test12
4 1004 12 test02 test34
5 1004 12 test06 test56
6 1005 11 test17 test67
7 1005 12 test07 test57
8 1006 13 test05 test98
9 1007 13 test02 test93
10 1008 14 test01 test03
... .... ... ...... ......
Now, I would like to select only the rows when Text2 change. So the
result of such query should look like:
Id Text1 Text2 Text3 Text4
-----------------------------------
1 1001 11 test03 test13
3 1003 12 test04 test12
6 1005 11 test17 test67
7 1005 12 test07 test57
8 1006 13 test05 test98
10 1008 14 test01 test03
... .... ... ...... ......
How should this query look like?
select * from tableName t1
where t1.Text2 != (
select t2.Text2 from tableName t2
where t2.Id < t1.Id
order by t2.Id desc limit 1
);
Igor Tandetnik
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------