select distinct t.lo_num '经度1', t.la_num '纬度1', t.short_str '名称1', '距离(Km)' 'jl', A1.lo_num '经度2', A1.la_num '纬度2', A1.proj_str '名称2', e.jl as '距离' from dc_tproject_d t left join dc_market_tproj_f f on t.proj_id = f.proj_id left join ( select distinct proj_id, lo_num, la_num, short_str 'proj_str' from dc_tproject_d union all select distinct tproj_id 'proj_id', lo_num, la_num, proj_str from dc_cproject_d ) A1 on t.proj_id = A1.proj_id left join (SELECT distinct proj_id, ROUND( 6378.137*2*ASIN(SQRT(power(SIN((la_num2-la_num1)/2),2)+COS(la_num2)*COS(la_num1)*power(SIN((lo_num2-lo_num1)/2),2) ) ) ,1) as jl FROM ( select distinct proj_id, lo_num_t* PI() / 180 as lo_num1, lo_num_c* PI() / 180 as lo_num2, la_num_t* PI() / 180 as la_num1, la_num_c* PI() / 180 as la_num2 from( SELECT distinct t.proj_id,t.lo_num AS lo_num_t,t.la_num AS la_num_t,c.lo_num AS lo_num_c,c.la_num AS la_num_c from dc_tproject_d t left join dc_cproject_d c on t.proj_id = c.tproj_id ) a ) b ) e on t.proj_id = e.proj_id where t.region_id = '${region_id}' and t.city_id = '${city_id}' and t.proj_id = '${proj_id}' and len(t.lo_num) <> 0 and len(t.la_num) <> 0 and len(A1.lo_num) <> 0 and len(A1.la_num) <> 0
我这个写出来数据重复太多了,帮忙改一下,不要有重复数据
拿这个结果集说: 应该有四条数据 烟台玖熙墅-->烟台玖熙墅,距离:0 烟台玖熙墅-->磁山温泉小镇,距离:?? 烟台玖熙墅-->招商马尔贝拉,距离:?? 烟台玖熙墅-->龙湖葡醍海湾,距离:?? |