2

在 SQL Server 2008 中,但未出现列名。我需要输入一个空字符串,因为这些行是在报告中手动填充的。

(SELECT '' As 'Total No of people')

它似乎显示为(No column name)

4

3 回答 3

6

你可以有

SELECT ID as 'ID',
(SELECT <....> FROM table WHERE <...> ) AS 'Total No of people'
FROM somewhere

您必须将列名放在)内部选择之后

于 2013-08-05T09:39:35.243 回答
3

我会说它工作正常!http://sqlfiddle.com/#!3/d41d8/18149

但也许你的问题是你这样做(技术上使用子查询)

SELECT ID, (SELECT '' As 'Total No of people') FROM SomeWhere

那是错误的……

SELECT ID, '' As 'Total No of people' FROM SomeWhere

或者

SELECT ID, (SELECT '') As 'Total No of people' FROM SomeWhere

但没有内在的原因SELECT

于 2013-08-05T09:33:12.730 回答
0

确保您按顺序排列: SELECT '' As 'Total No of people' from PEOPLE

于 2013-08-05T09:40:59.997 回答