-3
Jurisdiction Route
------------ -----
Portland 65
Portland 55
Cornelius 75
Cornelius 75
Cornelius 75
如何計算cornelius的路由數量?答案是1子查詢SQL計數功能
Jurisdiction Route
------------ -----
Portland 65
Portland 55
Cornelius 75
Cornelius 75
Cornelius 75
如何計算cornelius的路由數量?答案是1子查詢SQL計數功能
SELECT COUNT(*)
FROM your_table
GROUP BY Jurisdiction, Route
WHERE Jurisdiction = 'Cornelius'
或者
SELECT COUNT(DISTINCT Route)
FROM your_table
GROUP BY Jurisdiction
WHERE Jurisdiction = 'Cornelius'
你只需要使用COUNT()
和DISTINCT
select count(distinct Jurisdiction) total, Jurisdiction
from table1
where Jurisdiction = 'Cornelius'
group by Jurisdiction