更新时间:2024-06-29 GMT+08:00
NAMED
Teradata中的NAMED用于为表达式或列分配临时名称。用于表达式的NAMED语句在DWS中被迁移为AS。用于列名的NAMED语句保留在相同的语法中。
输入:NAMED表达式,迁移为AS
1 2 3 |
SELECT Name, ((Salary + (YrsExp * 200))/12) (NAMED Projection) FROM Employee WHERE DeptNo = 600 AND Projection < 2500; |
输出
1 2 3 |
SELECT Name, ((Salary + (YrsExp * 200))/12) AS Projection FROM Employee WHERE DeptNo = 600 AND ((Salary + (YrsExp * 200))/12) < 2500; |
输入:NAMED AS,定义列名
1 2 |
SELECT product_id AS id FROM emp where pid=2 or id=2; |
输出
1 2 |
SELECT product_id (NAMED "pid") AS id FROM emp where product_id=2 or product_id=2; |
输入:NAMED( ),定义列名
1
|
INSERT INTO Neg100 (NAMED,ID,Dept) VALUES ('TEST',1,'IT'); |
输出
1
|
INSERT INTO Neg100 (NAMED,ID,Dept) SELECT 'TEST',1, 'IT'; |
输入:NAMED别名,使用TITLE别名,不使用AS
1 2 3 |
SELECT dept_name (NAMED alias1) (TITLE alias2 ) FROM employee WHERE dept_name like 'Quality'; |
输出
1 2 3 4 |
SELECT dept_name AS alias1 FROM employee WHERE dept_name like 'Quality'; |
输入:NAMED别名,使用TITLE别名和AS
DSC将跳过NAMED别名和TITLE别名,仅使用AS别名。
1 2 3 4 |
SELECT sale_name (Named alias1 ) (Title alias2) AS alias3 FROM employee WHERE sname = 'Stock' OR sname ='Sales'; |
输出
1 2 3 4 |
SELECT sale_name AS alias3 FROM employee WHERE sname = 'Stock' OR sname ='Sales'; |
输入:NAMED,使用TITLE
NAMED和TITLE一起使用,通过逗号隔开。
1 2 3 |
SELECT customer_id (NAMED cust_id, TITLE 'Customer Id') FROM Customer_T WHERE cust_id > 10; |
输出
1 2 3 4 |
SELECT cust_id AS "Customer Id" FROM (SELECT customer_id AS cust_id FROM customer_t WHERE cust_id > 10); |
父主题: 数据操作语句(DML)