SQL 查询非重复计数问题
SQL Query Distinct Count Issue
我正在尝试获取每个制造商下的型号数量,在 table 我想显示如下内容:
Manufacturer Models
Honda 7
Ford 12
例如雅阁、思域等车型...
我怎样才能得到这个数字?在 SQL table 中是这样布局的
Manufacturer Models
Honda Accord
Honda Civic
Ford F150
Ford Taurus
等等....
在 table 中,我想像上面那样布局....
使用 GROUP BY and COUNT 和 DISTINCT 的查询:
SELECT Manufacturer
,COUNT(DISTINCT Models) as DistinctModels
FROM myTable
GROUP BY Manufacturer
select Manufacturer
, count(*) total_models
from table
group by Manufacturer
order by Manufacturer
或不同的
select Manufacturer
, count(distinct Models) total_models
from table
group by Manufacturer
order by Manufacturer
我正在尝试获取每个制造商下的型号数量,在 table 我想显示如下内容:
Manufacturer Models
Honda 7
Ford 12
例如雅阁、思域等车型...
我怎样才能得到这个数字?在 SQL table 中是这样布局的
Manufacturer Models
Honda Accord
Honda Civic
Ford F150
Ford Taurus
等等....
在 table 中,我想像上面那样布局....
使用 GROUP BY and COUNT 和 DISTINCT 的查询:
SELECT Manufacturer
,COUNT(DISTINCT Models) as DistinctModels
FROM myTable
GROUP BY Manufacturer
select Manufacturer
, count(*) total_models
from table
group by Manufacturer
order by Manufacturer
或不同的
select Manufacturer
, count(distinct Models) total_models
from table
group by Manufacturer
order by Manufacturer