id name age desc
1 jack 20
2 king 21
3 king 21
4 lili 19
5 lili 20
6 lili 20
7 lili 19
找出字段name,age相邻的,相同的数据,取第一条。
结果应该是:
id name age desc
1 jack 20
2 king 21
4 lili 19
5 lili 20
7 lili 19
------解决方案--------------------
Select id, name, age From tb A Where Not Exists(Select ID From tb Where name = A.NAME AND age=A.age And ID = A.ID - 1)