gpt4 book ai didi

sql - Postgresql 选择常量

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

在 Oracle 中,我可以选择一个常量值来填充列,如下所示:

Select 
"constant" constantvalue,
orders.name
from
orders

它会产生:

ConstantValue     Name
constant sandwich
constant burger

无论出于何种原因,当我尝试在 postgres 中执行此操作时,我收到此错误。

ERROR:  column "Constant" does not exist

这是我的代码

    select
date_trunc('day', measurement_date + (interval '1 day' * (6 - extract(dow from measurement_date)))) week,
"AROutstanding" colname,
round(avg(Total_Outstanding),0) numbah
from
(
select
measurement_date,

sum(cast(sum_of_dollars as numeric)) Total_Outstanding
from
stock_metrics
where
invoice_status not in ('F','Write off')
group by
measurement_date
) tt
group by
week

最佳答案

将双引号更改为单引号。

所以这样:

Select 
"constant" as constantvalue,
orders.name
from
orders

应该是这样的:

Select 
'constant' as constantvalue,
orders.name
from
orders

关于sql - Postgresql 选择常量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35616982/

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