我在sparksql中运行一个配置单元查询,如下所示:
select
GREATEST(
CASE WHEN x1 = 2 then y1+3 else -1,
case when x2 = 2 then y2+3 else -1,
case when xe = 2 then y2+3 else -1,
.....
case when x100 = 2 then y100+3 else -1
)
as greatest_sum
from table
我需要为每行循环大约100列,并在应用case语句后获得最大值。我有100份案件陈述。我在寻找一种不重复100行的方法。我该怎么做?
在这个例子中,我使case语句变得简单,但是我的代码中每个case都跨越了15行,这使得重复不是最好的方法。
暂无答案!
目前还没有任何答案,快来回答吧!