我有一个相当简单的查询,主要是返回报告的相关数据。一个字段要求我修改数据(转EMPLOYEE
,转换为varchar
,并添加字符串),这需要SELECT CONVERT
行。我的问题是,当我希望转换的数据简单地落入结果时,这会将我的结果分成两个表。我知道这与我的第二个SELECT (SELECT CONVERT)
有关,但我不知道如何实现我的目标,即包含已转换数据的一个表。SQL Query
SELECT ID=''
,[LAST_NAME] AS [LNAME]
,[FIRST_NAME] AS [FNAME]
,[MIDDLE_NAME] AS [MNAME]
,[EMPLOYEE] AS [PERSON_NO]
FROM [LSLMDB].[ls_apps].[EMPLOYEE]
SELECT CONVERT(varchar(20),EMPLOYEE)+'xxxxx.org' AS [USERNAME]
,HOME_COMPANY='xxx'
,[DATE_HIRED] AS [HIRED_ON]
,[EMPLOYEE] AS [EMAIL]
,JOB_TYPE= ''
,[HM_ACCT_UNIT] AS [COMPANY]
FROM [LSLMDB].[ls_apps].[EMPLOYEE]
答案 0 :(得分:0)
尝试将您的查询更改为:
SELECT ID=''
,[LAST_NAME] AS [LNAME]
,[FIRST_NAME] AS [FNAME]
,[MIDDLE_NAME] AS [MNAME]
,[EMPLOYEE] AS [PERSON_NO]
,CONVERT(varchar(20),EMPLOYEE)+'xxxxx.org' AS [USERNAME]
,HOME_COMPANY='xxx'
,[DATE_HIRED] AS [HIRED_ON]
,[EMPLOYEE] AS [EMAIL]
,JOB_TYPE= ''
,[HM_ACCT_UNIT] AS [COMPANY]
FROM [LSLMDB].[ls_apps].[EMPLOYEE]