我们被要求创建一个 SQL 语句来显示国家/地区为美国的客户数量。然后,结果集的列名称应重命名为 numcustomers
。
数据库在这里:http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all .
我已经找到了美国的客户数量(*):
SELECT *
FROM Customers
WHERE Country = 'Germany'
但我不知道如何将 COUNT(*)
重命名为 numcustomers
。有什么帮助吗?
最佳答案
SELECT count(*) AS numcustomers FROM Customers
WHERE Country = 'USA'
使用AS
关键字设置列别名。
关于sql - 如何在 SQL 中重命名 COUNT(*) 结果集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39565394/