How to use "Field Filter" variable properly?, to make dropdown filter [SOLVED]

I want to make dropdown filter with custom choices, but firstly when I try to use "field filter" variable it always make an error, there is my query

SELECT count(*) AS Total, skel."REG" AS "region" FROM "PROFILE" bw
INNER JOIN "SETUP_REG" skel ON skel."NO_REG" = bw."NO_REG"
[[ WHERE (bw."JOB" = ({{job}})) AND 
bw."ENTRI_DATE" BETWEEN {{start_date}} AND {{stop_date}} ]]

it turn out error

ERROR: invalid reference to FROM-clause entry for table "PROFILE" Hint: Perhaps you meant to reference the table alias "bw". Position: 264

what should I do actualy?

Field filters won’t work if there’s a table alias in the query

oh I see, its work, but now remain another error

ERROR: operator does not exist: numeric = boolean Hint: No operator matches the given name and argument types. You might need to add explicit type casts. Position: 343

if job is a field filter, then you're using it wrong

the query should be
[[ WHERE (({{job}})) AND

being job and date field filters mapped to bw.job and bw.entri_date

check Field Filters: create smart filter widgets for SQL questions

oh right, thank you for the solution

1 Like