No Result in my query

Hi,

I wrote a very specific SQL query that also includes specific binning, I also need a City filter to work on this query before adding it to the dashboard. However, when I added the filter query it showed me this message (No Result). No matter what I do to my query it refuses to show me any result with the filter on.

Here is the code:

SELECT
FLOOR("source"."budget per person per month" / 100) * 100 AS bin_start,
FLOOR("source"."budget per person per month" / 100) * 100 + 9 AS bin_end,
COUNT(*) AS bin_count,
AVG("source"."budget per person per month") AS avg_budget_per_person
FROM (
SELECT
"public"."seeker_profile"."property_id" AS "property_id",
"public"."seeker_profile"."min_rooms" AS "min_rooms",
"public"."seeker_profile"."max_budget" AS "max_budget",
CAST("public"."seeker_profile"."max_budget" AS float) / NULLIF("public"."seeker_profile"."min_rooms", 0) AS "budget per person per month",
"Property Contract"."monthly_rent_per_person" AS "Property Contract__monthly_rent_per_person",
"Property Location"."property_id" AS "Property Location__property_id",
"Property Location"."city" AS "city"
FROM "public"."seeker_profile"
LEFT JOIN "public"."property_contract" AS "Property Contract" ON "public"."seeker_profile"."property_id" = "Property Contract"."property_id"
LEFT JOIN "public"."property_location" AS "Property Location" ON "public"."seeker_profile"."property_id" = "Property Location"."property_id"
) AS "source"
WHERE "source"."budget per person per month" BETWEEN 100 AND 3000
AND ("source"."city" = '{{city}}' OR '{{city}}' = '')
GROUP BY FLOOR("source"."budget per person per month" / 100), "source"."property_id"
ORDER BY bin_start;

Try adding the filter expression without the apostrophes:
AND ("source"."city" = {{city}} OR {{city}} = '')

it gave me a syntax error

What database are you using?
Also, could you paste the specific error you got without the apostrophes?

I am using my company's data .. Here is the error: ERROR: syntax error at or near "=" Position: 3012

Hey SarahBawazir

Is the intent to run the query regardless if a filter value for “City” is selected or not?
If so, take a look at SQL optional parameters. The “Budget” portion of the WHERE clause should be able to run, while the “City” portion is optional.

Thank you it worked:)