Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 用于从数据库中选择所有表的公式查询_Sql_Postgresql - Fatal编程技术网

Sql 用于从数据库中选择所有表的公式查询

Sql 用于从数据库中选择所有表的公式查询,sql,postgresql,Sql,Postgresql,我的数据来自PostGreSQL的两个表 这是一张桌子 wv1 rv1 341.6 2.48 343.6 2.58 344.7 2.37 346.3 2.32 347.9 2.29 349.5 2.36 351.1 2.23 352.6 2.24 354.2 2.25 355.8 2.29 357.4

我的数据来自PostGreSQL的两个表 这是一张桌子

wv1           rv1
341.6         2.48
343.6         2.58
344.7         2.37
346.3         2.32
347.9         2.29
349.5         2.36
351.1         2.23
352.6         2.24
354.2         2.25
355.8         2.29
357.4         2.28
358.9         2.23
另一张桌子

wv2        rv2
341.6      8.24
343.1      8.17
344.7      8.19
346.3      8.13
347.9      8.14
349.5      8.09
351.1      8.09
352.6      8.13
354.2      8.21
355.8      8.24
357.4      8.27
358.9      8.29
我使用的是数据rv1和rv2 公式是**

  • I=ACOS[rv1.rv2/| rv1 |.| rv2 |]
** 就是 **

  • I=Acos[(2.38*8.24)+(2.58*8.17)+(2.37*8.19)+……)/sqrt((2.38*2.38)+(2.58*2.58)+(2.37*2.37)+……)*sqrt((8.24*8.24)+(8.17*8.17)+(8.19*8.19)+……)
** 此项的PostGreSQL查询为

select
    acos(sum(t1.rv1 * t2.rv2) / (
        sqrt(sum(power(t1.rv1, 2))) * sqrt(sum(power(t2.rv2, 2)))
    )) as i
from
    t1
    inner join
    t2 on t1.wv1 = t2.wv2
在这个查询中,我想比较数据库中的所有表,而不是表2(t2)

最终输出

我想在PostGreSQL查询中编写公式,如何编写,请指导我

select
    acos(sum(t1.rv1 * t2.rv2) / (
        sqrt(sum(power(t1.rv1, 2))) * sqrt(sum(power(t2.rv2, 2)))
    )) as i
from
    t1
    inner join
    t2 on t1.wv1 = t2.wv2

wv1
wv2
必须是
唯一的
,才能工作

功能代码与您的文本不匹配。函数名不是
spec\u angle
?这些事情让人觉得你不知道你想要什么,所以任何努力都会被拒绝。非常感谢你,克罗多尔多·内托先生。工作正常
   Ivalue
   0.3559772512926 
   0.52684312
select
    acos(sum(t1.rv1 * t2.rv2) / (
        sqrt(sum(power(t1.rv1, 2))) * sqrt(sum(power(t2.rv2, 2)))
    )) as i
from
    t1
    inner join
    t2 on t1.wv1 = t2.wv2