Tableau-公用表表达式(CTE)SQL Server [英] Tableau - Common Table Expression (CTE) SQL Server

查看:120
本文介绍了Tableau-公用表表达式(CTE)SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Tableau与SQL Server连接,并且正在尝试使用T-SQL查询。
我只是想知道,Tableau是否支持CTE(通用表表达式)?

I am connecting Tableau with SQL Server and I am trying to use the T-SQL query. I just want to know, does Tableau support CTE (Common Table Expression)?

我碰到了这篇文章,它说CTE是可能的: http://kb.tableau.com/articles/howto/using-common-table -表达式

I came across this article and it said CTE is possible: http://kb.tableau.com/articles/howto/using-common-table-expressions

这是我的查询:

WITH Test (Store) AS 
(
    SELECT 
        Store
    FROM
        FiscalReporting.dbo.LBR_STR_ORG
)
SELECT
    Store
FROM
    Test

在运行此查询时,我收到一条错误消息。如果我做错了事,请告诉我。

When I am running this query, I get an error message. Please let me know if I am doing something wrong.

我的大多数SQL查询都是使用CTE构建的。因此,如果能得到任何帮助,将不胜感激。另外,我是Tableau的新手。

Most of my SQL queries are built with CTE. So it would be greatly appreciated if I get any help. Also, I am new to Tableau.

谢谢!

推荐答案

Tableau在自定义SQL中不支持CTE表达式。

Tableau does not support CTE expressions in "Custom SQL". But it does in "Initial SQL".

这里有两个示例,如何使用它:

Here are two examples, how to use it:

< a href = https://kb.tableau.com/articles/howto/using-common-table-expressions rel = nofollow noreferrer> https://kb.tableau.com/articles/howto/using-common -table-expressions

https://dabblingwithdata.wordpress.com/2016/12/10/actually-you-可以使用变量ctes和其他花式sql与Table-after-all /

该解决方案涉及使用初始SQL您可以在其中创建临时表(在开始时带有#的临时表-SQL Server),然后在自定义SQL中引用此临时表

The solution involves using "Initial SQL" where you can create temp table (the one with # at the beggining - SQL Server) and then you refer to this temp table in your "Custom SQL"

这篇关于Tableau-公用表表达式(CTE)SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆