一个重复记录的问题
表(kzw):
id xianlu_id point_name x y h biaod_id
1 19 草桥 314594.654 494252.073
2 19 草桥 314594.654 494252.073
3 19 北宫门 315032.232 492997.054
4 19 北宫门 315032.232 492997.054
5 19 北宫门 315032.232 492997.054 1
6 18 草桥 311013.473 496936.988 1
7 18 草桥 311013.473 496936.988
8 18 草桥 311013.473 496936.988 40.77
筛选结果:
id xianlu_id point_name x y h biaod_id
1 19 草桥 314594.654 494252.073
8 18 北三环路口 311013.473 496936.988 40.77
也就是以字段point_name查询,在相同的记录中任取一条记录
------解决方案--------------------select max(id),max(xianlu_id),point_name,max(x),max(y),max(h),max(biaod_id) from kzw group by point_name
------解决方案--------------------select *
from ta as a
where point_name=(select top 1 point_name from ta where id=a.id and xianlu_id=a.xianlu_id order by newid())
------解决方案--------------------order by newid()--取随机的point_name