gpt4 book ai didi

SQL Server - 将代码块放入 View /临时表

转载 作者:行者123 更新时间:2023-12-02 03:17:06 25 4
gpt4 key购买 nike

<分区>

抱歉上面的标题,我不太确定如何措辞,但这是要点......

我在下面找到了这个查询,它将计算经度和纬度两点之间的英里数......

DECLARE @sourceLatitude FLOAT = 53.0150594250908;  
DECLARE @sourceLongitude FLOAT = -2.24460456782419;
DECLARE @destinationLatitude FLOAT = 52.002933355733400;
DECLARE @destinationLongitude FLOAT = -0.976678285584733;
DECLARE @Location FLOAT
SET @Location = SQRT(POWER(69.1 * ( @destinationLatitude - @sourceLatitude),
2) + POWER(69.1 * ( @sourceLongitude
- @destinationLongitude )
* COS(@destinationLatitude / 57.3), 2))
PRINT @Location

现在基于 PRINT 结果,我正在尝试创建一个 View 来显示这些结果的列表。例如,我有一个名为 TableAddress 的表,其中包含一个地址列表

TableAddress   
Address Long Lat
Address 1 52.5600450207834 -0.274050229426521
Address 2 53.5746997938162 -0.62449270669287
Address 3 50.3404675259117 -5.15208822743251

我有一个包含目的地列表的 TableDestination:

TableDestination 
Address Long Lat
Destination 1 52.5063420216939 -2.07973524437415
Destination 2 50.9776014579626 -1.35438374178925
Destination 3 53.5493068199536 -0.679623916124968
  1. 用户将通过参数选择 AddressDestination
  2. 基于此结果,我想使用上述查询创建一个 View ,该 View 将列出每个地址距目的地的距离。

我不知道从哪里开始,所以有人可以为我指明正确的方向,告诉我如何实现这一目标吗?

非常感谢

示例结果:

 theView
AddressName DestinationName Distance
Address 1 Destination 1 38
Address 2 Destination 1 49
Address 3 Destination 1 16

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com