本文介绍了如何在雪花中运行光标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在SQL和工作文件中写了下面的游标。但是我无法在雪花上运行相同的光标,请帮助。

DECLARE @CurrentMonth NVARCHAR(100)
DECLARE @CurrentMonth1 NVARCHAR(100)
DECLARE MYDateCURSOR CURSOR
DYNAMIC
FOR
SELECT Collections_COE FROM [CollectionsAgeing_OTCN024_028_029]
OPEN MYDateCURSOR
FETCH LAST FROM MYDateCURSOR INTO @CurrentMonth
CLOSE MYDateCURSOR
DEALLOCATE MYDateCURSOR
--select  value from STRING_SPLIT(@CurrentMonth,'-') ;
select @CurrentMonth1=LEFT(@CurrentMonth,4)+cast(cast(RIGHT(@CurrentMonth,2) as int)-1 as varchar(2))
select Date, x1,y1,x1/y1 as DividedValue, round((x1/y1)-1,5) as Actual from(
SELECT  X.Past_Due_0 as x1,Y.Past_Due_0 as y1,X.Collections_COE as Date FROM [CollectionsAgeing_OTCN024_028_029] X
CROSS JOIN [CollectionsAgeing_OTCN024_028_029] Y
WHERE X.Collections_COE=@CurrentMonth and y.Collections_COE=@CurrentMonth1
)z

推荐答案

Snowflake Scripting引入了对游标的支持。

这篇关于如何在雪花中运行光标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-24 01:03