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

问题描述

在MSSQL 2008中使用多个CTE时,我通常用逗号将它们分开。

When using multiple CTE's in MSSQL 2008, I normally separate them with a comma.

但是当我在Teradata环境中尝试使用此命令时,出现错误

But when I try this in a Teradata environment, I get an error with the syntax.

在MS SQL中工作:

Works in MS SQL:

WITH CTE1 AS 
(SELECT TOP 2 Name FROM Sales.Store)
,CTE2 AS 
(SELECT TOP 2 ProductNumber, Name FROM Production.Product)
,CTE3 AS 
(SELECT TOP 2 Name FROM Person.ContactType)
SELECT * FROM CTE1,CTE2,CTE3

尝试使用Teradata语法:

Now, attempting to put into Teradata syntax:

WITH RECURSIVE CTE1 (Name) AS 
(SELECT TOP 2 Name FROM Sales.Store)
,RECURSIVE CTE2 (ProductNumber, Name) AS 
(SELECT TOP 2 ProductNumber, Name FROM Production.Product)
,RECURSIVE CTE3 (Name) AS 
(SELECT TOP 2 Name FROM Person.ContactType)
SELECT * 
FROM CTE1,CTE2,CTE3



第二次尝试(不多次使用RECURSIVE)

/ p>

2nd attempt (without using RECURSIVE multiple times)

WITH RECURSIVE CTE1 (Name) AS 
(SELECT TOP 2 Name FROM Sales.Store)
,CTE2 (ProductNumber, Name) AS 
(SELECT TOP 2 ProductNumber, Name FROM Production.Product)
,CTE3 (Name) AS 
(SELECT TOP 2 Name FROM Person.ContactType)
SELECT * 
FROM CTE1,CTE2,CTE3




推荐答案

支持多个CTE Teradata的14.0版。您可以从Teradata开发人员网络网站下载适用于VMware的TD v14并进行测试。

Multiple CTEs are supported on version 14.0 of Teradata. You can download TD v14 for VMware from the Teradata Developer Network web site and test it out.

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

09-21 08:47