显示不存在的列的值

时间:2018-09-07 16:52:47

标签: sql sql-server sql-server-2008 oracle11g

在Oracle中,我可以为表中不存在的列定义值,例如

SELECT 
    C.CUSTOMER_ID, ' ' CUSTOMER_PHONE , 'JAMAICAN' CUSTOMER_NATIONALITY.

我需要知道我是否可以在SQL Server中实现相同的目标。

1 个答案:

答案 0 :(得分:3)

是的,非常相似...

SELECT 
    C.CUSTOMER_ID, 
    ,CUSTOMER_PHONE = ' ' 
    ,CUSTOMER_NATIONALITY = 'JAMAICAN' 
FROM
   YourTable

您还将看到此列的别名为AS

SELECT 
    C.CUSTOMER_ID, 
    ,' ' AS CUSTOMER_PHONE  
    ,'JAMAICAN' AS CUSTOMER_NATIONALITY  
FROM
   YourTable