选择中的配置单元子查询

wfsdck30  于 2021-05-27  发布在  Hadoop
关注(0)|答案(2)|浏览(453)

我有个问题

SELECT name, salary/ (SELECT max(money) from table_sal) FROM table_a;

我听到一个错误说

Unsupported SubQuery Expression Invalid subquery. Subquery in SELECT could only be top-level expression

有办法解决这个问题吗?

rqqzpn5f

rqqzpn5f1#

这个能用吗 CROSS JOIN ?

SELECT name, salary / s.max_money
FROM table_a CROSS JOIN
     (SELECT max(money) as max_money from table_sal) s
j13ufse2

j13ufse22#

你也可以这样做如下,请让我知道它是否适合你。

Select t1.name
      , t1.salary/T2.max_money
 from
   (SELECT name
         , salary, 1 as dummy
           from  table_a ) t1 
  Join
      (SELECT max(money) as max_money
            , 1 as dummy 
              from table_sal) t2
  on t1.dummy = t2.dummy ;

相关问题