PostgreSQL SQL错误:统计子查询唯一ID时出现double precision输入无效
嵌套SQL统计唯一ID时触发类型转换错误
执行一条包含多层嵌套子查询的SQL语句时,仅在外层尝试统计子查询中的唯一item_id时触发错误,单独运行各子查询均正常。
错误提示:
ERROR: invalid input syntax for type double precision: "promo_email_click"
我对此感到困惑:查询中未显式使用double precision类型,也未涉及"promo_email_click"相关内容。
附上的SQL语句如下:
SELECT COUNT(distinct test_) AS unique_item_ids_in_window FROM (SELECT -- only pull item_ids int_item_id AS test_ FROM (SELECT -- create a binary label for the events, where each event is either in the 30 days after test started window (1) or not (0) int_item_id, time_of_item_view, (CASE WHEN time_of_item_view > '2015-03-14 00:00:00' AND time_of_item_view < '2015-04-13 00:00:00' THEN CAST('1' as INT) ELSE CAST('0' AS INT) END) AS In_30_day_window FROM -- for the view_item events, turn the 'parameter value' from a string to a float (SELECT CAST (parameter_value AS FLOAT) AS int_item_id, event_time AS time_of_item_view FROM -- select only view_item events (SELECT * FROM dsv1069.events WHERE events.event_name = 'view_item') AS only_view_items ) AS parameter_value_turned_to_float ) AS only_in_30_day_window WHERE only_in_30_day_window.In_30_day_window = 1) AS ONLY_in_30_day_window_yes GROUP BY ONLY_in_30_day_window_yes.test_ -- tried ordering by test_ but keep getting an error
尝试对子查询使用聚合函数时反复出现该错误:
org.postgresql.util.PSQLException: ERROR: invalid input syntax for type double precision: "promo_email_click"
内容的提问来源于stack exchange,提问作者Alexander Saul Goldman
相关产品推荐
相关产品推荐

