0
我使用滯後函數將兩個表連接在一起,以便第一個表不顯示重複的度量行。使用LAG並比較列
但是,我在預先選擇連接時遇到了引用滯後列的問題。
我的查詢如下,提到的列標有!!!
select "Campaign",
"Ad group" ,
"Final URL" ,
"Headline 1" ,
"Headline 2" ,
"Description" ,
"Path 1" ,
"Path 2" ,
"Status" ,
"Labels" ,
case when prev_key is null or prev_key != "Key" then "Clicks" end as
"Clicks",
case when prev_key is null or prev_key != "Key" then "Impressions" end
as
"Impressions",
case when prev_key is null or prev_key != "Key" then "Cost" end as
"Cost",
case when prev_key is null or prev_key != "Key" then "Avg. position" end
as
"Avg. position",
case when prev_key is null or prev_key != "Key" then "Initial Leads" end
as
"Initial Leads",
case when prev_key is null or prev_key != "Key" then "Evaluations" end
as
"Evaluations",
case when prev_key is null or prev_key != "Key" then "Won Leads" end as
"Won Leads",
case when prev_key is null or prev_key != "Key" then "Opportunities" end
as
"Opportunities",
"Language",
"Network",
"Main Keyword",
"Cluster Keyword 1",
"Match Type"
from
(SELECT
"x"."Campaign",
"x"."Ad group",
"x"."Final URL",
"x"."Headline 1",
"x"."Headline 2",
"x"."Description",
"x"."Path 1",
"x"."Path 2",
"x"."Status",
"x"."Labels",
!!!lag ("x"."Key") over() AS prev_Key!!!,
"x"."Clicks",
"x"."Impressions",
"x"."Cost",
"x"."Avg. position",
"x"."Initial Leads",
"x"."Evaluations",
"x"."Won Leads",
"x"."Opportunities",
"x"."Language",
"x"."Network",
"x"."Main Keyword",
"x"."Cluster Keyword 1",
"x"."Match Type"
FROM ad_copies_final_joined_concatenated x join
ad_copies_final_to_join_concatenated
using ("Key")
order by "Campaign" desc, "Key"
) sub ;
輸出錯誤信息如下;
ERROR: column "Key" does not exist LINE 11: case when prev_key is null or prev_key != "Key" then "Cli... ^