gpt4 book ai didi

postgresql - 使用不同时为 "could not identify an equality operator for type json"

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

我有以下查询:

SELECT 
distinct(date(survey_results.created_at)),
json_build_object(
'high',
ROUND(
COUNT(*) FILTER (WHERE ( scores#>>'{medic,categories,motivation}' in('high', 'medium'))) OVER(order by date(survey_results.created_at) ) * 1.0 /
(
CASE (COUNT(*) FILTER (WHERE (scores#>>'{medic,categories,motivation}' in('high','medium','low'))) OVER(order by date(survey_results.created_at)))
WHEN 0.0 THEN 1.0
ELSE (COUNT(*) FILTER (WHERE (scores#>>'{medic,categories,motivation}' in('high','medium','low'))) OVER(order by date(survey_results.created_at)))
END)* 100, 2 ) ) AS childcare FROM survey_results GROUP BY date, scores ORDER BY date asc;

问题在于使用 distinct(date(survey_results.created_at))。有了那个地方查询返回错误:

could not identify an equality operator for type json

Here is db fiddle表明那个问题。我该如何解决?

最佳答案

使用jsonb_build_object。注意 json 之后的二进制文件 b

关于postgresql - 使用不同时为 "could not identify an equality operator for type json",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48420438/

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