Search code examples
sqlpostgresqlmetabase

(Editied): Error executing query in metabase: (ERROR: syntax error at or near "and" Position: 33)


I am running a very simple query in Metabase, however, I am getting an error. Following is the code I am running:

SELECT user_id
FROM order_order
[[where date_placed between {{from}} and {{to}}]]
and {{partner_id}}

Following is the error I am getting:

ERROR: syntax error at or near "and" Position: 33

I have been trying multiple ways to get this fixed, but couldn't get this to work. I would appreciate your help with this query. I don't see a problem with the query tho. What am I missing?

Attaching image for refrence


Solution

  • I think you just want:

    SELECT user_id  
    FROM order_order  
    where
    {{partner_id}}
    [[and {{date}}]] 
    

    then use an advanced date query to do the between part?

    All from memory so hope I'm not way off.