在union SQL中添加空白列

时间:2018-05-02 18:30:25

标签: sql sql-server datasource tableau

SELECT 
[wo#],
[COL2] as "Team"   
FROM T1
union 
select [request_external_wo_number], ' '
from T2

我想在tableau数据源中添加一个空白列。我有这个代码在SSMS中工作正常。但是,当我将其传输到Tableau时,它不起作用。除了''

之外还有更好的语法吗?

The error I receive in Tableau when attempting all possibilities. Everything works fine, I get output when I comment out the troublesome blank column.

1 个答案:

答案 0 :(得分:0)

您也可以null

离开
SELECT [wo#] as "col1", [COL2] as "Team"   
FROM T1 UNION  
SELECT [request_external_wo_number], null
FROM T2

这将在Team表的T2列下生成空白字段,因为您不会为 SQL添加额外开销