Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2008 如何添加SQL数据库中不存在的静态列_Sql Server 2008 - Fatal编程技术网

Sql server 2008 如何添加SQL数据库中不存在的静态列

Sql server 2008 如何添加SQL数据库中不存在的静态列,sql-server-2008,Sql Server 2008,我有一个select查询,它显示了两列(文件类型和位置),我还需要一个表中不存在的列(区域)。此外,此列应包含基于某个位置类型列的值 FileType Location Region ------------------------------ 3 25 New York ============= 2 25 New York ============= 1 26 London ======================================= 如果位置为25,则区域类型应

我有一个select查询,它显示了两列(文件类型和位置),我还需要一个表中不存在的列(区域)。此外,此列应包含基于某个位置类型列的值

FileType Location Region 
------------------------------

3 25 New York
=============

2 25 New York
=============

1 26 London
=======================================
如果位置为25,则区域类型应显示为纽约和 如果位置为26,则区域类型应显示为伦敦


提前谢谢,我希望有人能在这方面帮助我。

谢谢@igor..感谢您的帮助。@rishabhshukla-如果这解决了您的问题,请考虑使用答案左侧的复选框将其标记为答案。
SELECT FileType
   , Location
   , CASE Location WHEN 25 THEN 'New York' WHEN 26 THEN 'London' ELSE NULL END AS Region
FROM ...