syntax error line 10 at position 20 unexpected '<EOF>'. (line 2)當我嘗試在 Snowflake 中運行以下查詢時收到錯誤訊息。有人可以告訴我如何解決這個問題嗎?
declare newline nvarchar(4);
set newline = char(13) || char(10);
select t.branchid,
listagg(l.loanidnumber, :newline) within group(order by t.encompassid) as assoc_loan_nums,
listagg(t.encompassid, :newline) within group(order by t.encompassid) as assoc_enc_ids
from tpo t
join loan l
on t.encompassid = l.encompassid
group by t.branchid;
uj5u.com熱心網友回復:
首先,我在您的代碼中添加了 BEGIN 和 END 塊。這是解決第一個錯誤。
但是,由于 char(),我得到了另一個錯誤。這真的是你想做的嗎?CHAR 基本上不是轉換為字符(字串),而是將代碼點轉換為與輸入 Unicode 匹配的字符。如果輸入錯誤,則會拋出錯誤:https ://docs.snowflake.com/en/sql-reference/functions/chr.html
基本上下面的代碼可以使用字串連接(如果這是您想要做的)。如果沒有,請將此視為起點。
declare newline nvarchar(4);
begin
set newline = concat('13', '10');
select t.branchid,
listagg(l.loanidnumber, :newline) within group(order by t.encompassid) as assoc_loan_nums,
listagg(t.encompassid, :newline) within group(order by t.encompassid) as assoc_enc_ids
from tpo t
join loan l
on t.encompassid = l.encompassid
group by t.branchid;
end;
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/523913.html
標籤:sql雪花云数据平台
上一篇:SSRS和填充運算式
