将邮政编码插入Microsoft Visual Studio 2013中的自定义组

时间:2015-07-15 11:07:49

标签: sql visual-studio-2012

我正在努力想出一个SQL脚本插入到Microsoft Visual Studio 2013中的数据集>在SQL下查询部分。我有一个巨大的邮政编码列表和每个邮政编码的自定义名称。例如,GL50 4PE是Cheltenham 001A,GL50 4SD是Cheltenham 001B。

我设想写一些类似的东西:

CASE
  WHEN TABLE.ATTRIBUTE IN (GL50 4PE)
THEN 'Cheltenham 001A'
  WHEN TABLE.ATTRIBUTE (GL50 4SD)
THEN 'Cheltenham 001B'
END AS NEWCOLUMNNAME

有什么想法吗?我会继续为我拥有的每个邮政编码添加WHEN TABLE.ATTRIBUTE IN (GL50 4PE) THEN 'Cheltenham 001A'。我需要为不同领域和邮政编码执行此操作,并在构建完毕后重新运行报告。

我在visual studio中的代码添加了部分内容:

SELECT        MONTH(HISTORY.DateStart) AS Month, HISTORY.Category_ID,        HISTORY.Learner_ID, NCS.Postcode, Learners_PriorityGroup.PriorityGroup, 
                     YEAR(HISTORY.DateStart) AS Year, HISTORY.DateStart,     HISTORY.HistoryID,
CASE WHEN NCS.POSTCODE IN (GL50 4SD)
THEN 'CHELTENHAM OD1A'
END AS LSOANAME
FROM            NCS INNER JOIN
                     HISTORY ON NCS.Learner_ID = HISTORY.Learner_ID INNER     JOIN
                     Learners_PriorityGroup ON HISTORY.Learner_ID =     Learners_PriorityGroup.Learner_ID
WHERE        (HISTORY.Category_ID IN (479, 480, 481, 482)) AND        (Learners_PriorityGroup.PriorityGroup = 0)                          

0 个答案:

没有答案