Reputation: 1
SELECT
count(
distinct "public"."cnpy_portfolio_current_snapshot"."userid"
) AS "count"
FROM
"public"."cnpy_portfolio_current_snapshot"
INNER JOIN (
SELECT
tenderneutralledgerid as ledgerid,
userid,
tnl.merchantprogramid,
tm.merchantid
FROM
tdym_tender_neutral_ledgers as tnl
INNER JOIN tdym_merchant_programs as tm ON tnl.merchantprogramid = tm.merchantprogramid
where {{createdat}}
UNION
SELECT
rewardledgerid as ledgerid,
userid,
tm.merchantprogramid,
tm.merchantid
FROM
tdym_reward_ledgers as tl
INNER JOIN tdym_merchant_programs as tm ON tl.merchantid = tm.merchantid
where {{createdat}}
) AS "Join all Reward Ledgers - Userid" ON "public"."cnpy_portfolio_current_snapshot"."userid" = "Join all Reward Ledgers - Userid"."userid"
INNER JOIN "public"."tdym_merchants" ON "Join all Reward Ledgers - Userid"."merchantid" = "public"."tdym_merchants"."merchantid"
WHERE {{merchantname}}
I am working on this query, merchantname and createdat are the variables in metabase, but I am repeatedly getting this weird error. Its not just this query, most of the queries i am using feild filter of date variables are giving this error
ERROR: invalid reference to FROM-clause entry for table "ra_orders" Hint: Perhaps you meant to reference the table alias "a".
I tried in various queries but it didn't work.
Upvotes: 0
Views: 91