gpt4 book ai didi

sql - PostgreSQL 到_日期()

转载 作者:行者123 更新时间:2023-11-29 12:45:16 25 4
gpt4 key购买 nike

我在使用 PostgreSQL to_date() 函数时遇到问题,在我下面提到的代码中出现语法错误,但找不到位置。

SELECT * from crosstab('select upit, sat, count(*) as broj
from upiti
where datum >= to_date('26-10-2014','DD-MM-YYYY') AND datum <= to_date('29-10-2014','DD-MM-YYYY')
group by upit,sat
ORDER BY upit,sat',

'select rbrSat from sat order by rbrSat') as ct (upit text, s00 INT, s01 INT, s02 INT, s03 INT, s04 INT, s05 INT, s06 INT, s07 INT, s08 INT, s09 INT, s10 INT, s11 INT, s12 INT, s13 INT, s14 INT, s15 INT, s16 INT, s17 INT, s18 INT, s19 INT, s20 INT, s21 INT, s22 INT, s23 INT);

它说语法错误在“2014”附近。谁知道问题出在哪里?

最佳答案

您正在尝试在单引号字符串中使用未转义的单引号 '。如果您需要在字符串中添加单引号,则需要将其加倍,如 '';

SELECT * from crosstab('select upit, sat, count(*) as broj
from upiti
where datum >= to_date(''26-10-2014'',''DD-MM-YYYY'')
AND datum <= to_date(''29-10-2014'',''DD-MM-YYYY'')
group by upit,sat
ORDER BY upit,sat',

...

关于sql - PostgreSQL 到_日期(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26574313/

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