【发布时间】:2019-06-23 01:34:54
【问题描述】:
我有一个名为 get_distance(point1,point2) 的函数,它计算两点之间的距离。我想计算我的表(几何)的列(点)的第一行中的点与已定义的变量(point_variable)之间的距离。我正在运行以下无法终止的查询:
-- Assume point_variable has already been defined as a varchar and
-- has a value
-- Assume that there is a column (points) in my table
-- (geometry) with only points stored as varchar
-- Also, assume that there is a scalar function (get_distance) that
-- takes as input two points (as 2 varchar parameters)and computes
-- and returns the distance as an int
SELECT get_distance(point_variable, (SELECT TOP 1 points from
geometry))
我正在运行之前的代码并且查询永远不会终止。我的目标是获取点列顶行中的条目与变量 point_variable 之间的距离。我应该如何尝试解决这个问题?
【问题讨论】:
-
当您提出 SQL 问题时,请确定您使用的是哪个 DBMS。 DBMS 的答案各不相同。
标签: sql