我的查询类似于以下内容:
select firstname, lastname
from names
where firstname = 'john'
我希望得到以下内容(概念上):
select
[names.firstname + names.lastname] as 'fullname'
from names
where names.firstname = 'john'
当然,这会返回无效的列名'names.firstname + names.lastname'。
是否可以返回包含同一个表中两列结果的单个别名列?
答案 0 :(得分:1)
感谢您的评论;在这种情况下,看起来以下内容将根据需要起作用:
CONCAT(ISNULL(names.FirstName, '(No First Name)',
' ', ISNULL(names.LastName, '(No Last Name)')) AS 'FullName'