Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 views
in Technique[技术] by (71.8m points)

The second argument for 'concat' must be a string or a char

我在DolphinDB中执行下列代码:

db = database("dfs://transport")
tb = select top 1000 * from db.loadTable(`autos)
select concat(concat(concat(string(yearOfRegistration),"."),string(monthOfRegistration)),".01") as newcat from tb

报错:The second argument for 'concat' must be a string or a char。其中yearOfRegistration和monthOfRegistration两个字段的类型都是INT。数据如下图所示:
image.png
请问怎么解决?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

参阅用户手册中concat的说明,第二个参数只能是字符串或字符。你在计算concat(concat(string(yearOfRegistration),"."),string(monthOfRegistration))这个时,第二个参数值是string(monthOfRegistration),这个是字符串向量了,所以报错。可试试下面代码:

select string(yearOfRegistration) + "." + string(monthOfRegistration) + ".01" as newcat from tb

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...