Issue with variables in SQL query

Hi All,

I’m trying to insert a field filter to the following query so that I can filter by Name. It looks like the variable in this instance does not work on the joined table “salesforce.user d”. I’ve tried multiple options but I can’t make it work. For context, the “Name” field is coming from the “salesforce.user d” table.

Would love to know if anybody has any clue on how to make it work?

a.user_id, AS “Account Name”,
b.company_tier_c AS “Company Tier”,
b.account_mrr_c “Current Account MRR”,
b.last_contract_end_date_c AS “Contract End Date”,
DATEDIFF(days,b.last_contract_end_date_c, CURRENT_DATE) AS “Days Before Contract Ending”,
c.balance/100 as “Available Content Balance”,
FROM salesforce.account_team_member a
LEFT JOIN salesforce.account b
LEFT JOIN contently_public.brand_profiles c
LEFT JOIN salesforce.user d
WHERE {{name}}
AND b.type = ‘Brand / Division’
AND a.team_member_role = ‘Account Manager’

Looking forward to your help,


If you’re using a field filter you can’t use a table alias.
In my sample data
This works:

SELECT * from customer where  {{test}}

This doesn’t:

SELECT * from customer c where  {{test}}

Either remove the alias or use a variable type of text (but then you’ll lose the list of values).

Hi Andrew,

Removing the alias won’t work in this case as there are multiple join. I’ve tried to give the name of the table as Alias but for some reason it still not working as I can’t call the user table as “user”.

account_team_member.user_id, AS “Account Name”,
account.company_tier_c AS “Company Tier”,
account.account_mrr_c “Current Account MRR”,
account.last_contract_end_date_c AS “Contract End Date”,
DATEDIFF(days,account.last_contract_end_date_c, CURRENT_DATE) AS “Days Before Contract Ending”,
brand_profiles.balance/100 as “Available Content Balance”,
FROM salesforce.account_team_member as account_team_member
LEFT JOIN salesforce.account as account
LEFT JOIN contently_public.brand_profiles as brand_profiles
LEFT JOIN salesforce.user as user
WHERE {{name}}

any ideas on how to make this work?

@flo92 Why can’t you just use skip the alias for the table you’re using with Field Filter?
LEFT JOIN salesforce.user ON

There’s an issue open on support for table aliases: - upvote by clicking :+1: on the first post

1 Like

Thanks, Flamber! looks like it’s working!