(编辑):在metabase中执行查询的错误:(错误:and&quot&quot&quot'&quot'stose:33)的语法错误

发布于 2025-02-09 18:01:12 字数 493 浏览 4 评论 0原文

我在Metabase中运行一个非常简单的查询,但是,我遇到了一个错误。 以下是我正在运行的代码:

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

以下是我遇到的错误:

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

我一直在尝试多种解决此问题的方法,但无法使其工作。感谢您在此查询方面的帮助。我看不到查询的问题。我想念什么?

for Refrence 附加图像

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

失退 2025-02-16 18:01:13

您查询中[[]]内部的语句仅在从或到变量具有选定值时使用。这意味着,当未设置和要设置的两个值(未选择的值)时,您的查询将如下:

 选择user_id
来自order_order
和{{canter_id}}
 

因此错误。
为了解决它,您应该将其中的子句设置为始终为真,然后具有所需的条件语句。这是一个示例:

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

The statement inside the [[ ]] in your query is only used when from or to variables have a selected value. That means that when both from and to are not set (no value selected) your query will be the following:

SELECT user_id
FROM order_order
and {{partner_id}}

hence the error.
In order to resolve it you should set the where clause to always true and then have the conditional statements that you want. Here is an example:

SELECT user_id  
FROM order_order  
where true  
[[and date_placed between {{from}} and {{to}}]] 
and {{partner_id}}
靖瑶 2025-02-16 18:01:12

我认为您只想:

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

然后使用高级日期查询进行两部分之间的操作?

全部记忆中,希望我不会离开。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文