gpt4 book ai didi

string - 创建文本字符串得到错误的输出(postgresql)

转载 作者:行者123 更新时间:2023-11-29 14:18:31 24 4
gpt4 key购买 nike

我正在尝试创建一个文本字符串供以后在半动态交叉表函数中使用。

只要我不使用格式“numeric(x,x)”,一切都很好

SELECT concat('sign varchar,',(SELECT string_agg(col,',') 
FROM (SELECT to_char(generate_series('2016-01-01','2016-01-15', interval '1 week'),'\"iyyy-iw\" numeric(10,2)')col )cols))

输出很奇怪。字母“i”替换为数字。

sign varchar,"2015-53" numer5c(10,2),"2016-01" numer6c(10,2),"2016-02" numer6c(10,2)

如何获得以“numeric(x,x)”作为列格式的正确文本字符串?

SQLfiddle:http://sqlfiddle.com/#!15/9eecb7db59d16c80417c72d1e1f4fbf1/10313

TIA,

最佳答案

在格式字符串中写入 "numeric(10,2)" 而不是 numeric(10,2)

The fine manual说:

Ordinary text is allowed in to_char templates and will be output literally. You can put a substring in double quotes to force it to be interpreted as literal text even if it contains pattern key words.

关于string - 创建文本字符串得到错误的输出(postgresql),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38692907/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com