2011-05-22 49 views

回答

2

尽管它很奇怪,该表具有重复的id列h ERE是,将显示结果的查询,你需要:

select id, city, road1, road2, lat, long 
from 
(
    select *, row_number() over(partition by id, city, lat, long order by road1, road2) RowNumber 
    from tbltest 
) tt 
where RowNumber = 1 
+0

@Pawan - 没有工作? – 2011-05-23 16:35:18

0

Using Common Table Expressions

;with tbl as 
(
    select *, row_number() over(partition by id, city order by road1, road2) RowNumber 
    from tbltest 
) 

select * from tbl 
where RowNumber = 1 
相关问题