试着到处寻找这个,但我的搜索没有给我任何答案。 想要计算“郊区”一栏中出现“悉尼”这个词多少次
CustomerId FirstName LastName StreetAddress Suburb PostCode
C001 James Smith 400 Kent St Sydney 2000
C002 Maria Carpenter 333 Smith St Westmead 2145
C003 Dennis Miller 214 Uni Rd Sydney 2000
我希望它能提供如下结果:
numCustomersFromSydney
2
答案 0 :(得分:6)
使用这个简单的查询:
select count(*) as numCustomersFromSydney from table where Suburb = "Sydney";
答案 1 :(得分:0)
使用COUNT()和别名:
SELECT
COUNT(Suburb) AS numCustomersFromSydney
FROM
yourtable
WHERE
Suburb = 'Sydney'