select tab2.dot1,tab1.dot2,tab2.distance From a as tab1,(select dot1,Min(distance) From a group by dot1 order by dot1) as tab2 where tab1.dot1=tab2.dot1 and tab1.distance=tab2.distance
select distinct a.dot1,a.dot2 ,a.distance from A a, where (select * from A where dot1=a.dot1 and a.distance<=all(select distance from a where dot1=a.dot1))
sele distinct x.dot1 as dot1,x.dot2 as dot2,x.distance as distance from a x,a y where x.dot1=y.dot1 and x.distance<=all(sele distance from a where dot1=x.dot1)
没有测试,你先试试:
SELECT dot1,min(distance) as min_distance FROM A into cursor cTemp GROUP BY dot1
Select A.dot1,A.dot2,A.distance From A ;
Left Join cTemp On A.dot1 = cTemp.dot1 And A.distance = cTemp.min_distance;
Where Not(Isnull(A.dot1) Or Empty(A.dot1))
select tab2.dot1,tab1.dot2,tab2.distance From a as tab1,(select dot1,Min(distance) From a group by dot1 order by dot1) as tab2 where tab1.dot1=tab2.dot1 and tab1.distance=tab2.distance
可以使用多个语句来进行吗?
如果可以,你可以参考一下这个:(最好在程序中使用了)
sele distinct dot1 from A order by dot1
count to num1
dimension arr1(num1,1)
copy to array arr1
for i=1 to num1
sele * from A where dot1=arr1(i,1) order by distance nowait
count to num2
dimension arr2(num2,3)
copy to array arr2
?arr2(i,1),arr2(i,2),arr2(i,3)
next
这样就能把你想要的结果显示出来。这样你可以解决你想要的东西,比如表形式的结果,其他等等!~