去除重复多余的点的SQL语句如何写?
有这样一个表:
Id X Y
85628113.092161662877 23.0536316670477
85630113.092161662877 23.0536316670477
85634113.092161662877 23.0536316670477
85648113.092226661742 23.053621664643298
85662113.093864999712 23.0529966689646
85677113.096401669085 23.043886665254799
85691113.104556664824 23.042911667376799
85704113.10559166222799 23.044330000877402
85719113.10559166222799 23.044330000877402
85732113.10559166222799 23.044330000877402
85747113.10499166697301 23.0446499995887
85761113.104084998369 23.057998333126299
85775113.11356999725101 23.069721668958699
想通过SQL查询得到如下结果如何进行:
Id X Y
85628113.092161662877 23.0536316670477
85648113.092226661742 23.053621664643298
85662113.093864999712 23.0529966689646
85677113.096401669085 23.043886665254799
85691113.104556664824 23.042911667376799
85704113.10559166222799 23.044330000877402
85747113.10499166697301 23.0446499995887
85761113.104084998369 23.057998333126299
85775113.11356999725101 23.069721668958699
即查询时x,y完全相同的纪录只保留一条。请问如何实现
[解决办法]
Try this query:
SELECT MIN(ID) AS ID, X, Y
FROM table_name
GROUP BY X, Y
[解决办法]
select * from 表 a
where not exists(select 1 from 表 where x=a.x and y=a.y and id> a.id)