我有以下查询:
SELECT sum(qty) AS TotalItems FROM Sales.OrderDetails;
然后返回
+------------+
| TotalItems |
+------------+
| 51317 |
+------------+
但是,我希望输出读取
+------------------------------+
| TotalItems |
+------------------------------+
| Total items ordered is 51317 |
+------------------------------+
我该怎么做?
答案 0 :(得分:1)
如果您使用的是Sql Server 2008,请尝试:
SELECT 'Total items ordered is ' + cast(sum(qty) as varchar(max)) AS TotalItems
FROM Sales.OrderDetails;
答案 1 :(得分:1)
您的数据库可能是Oracle,然后您应该尝试:
SELECT 'Total items ordered is ' || cast(sum(qty) as varchar(max)) AS TotalItems
FROM Sales.OrderDetails