-1

对于给定的表

1st column=producer
2nd column=type

A a
A a
A a
A b

B c
B c
B c

我想计算非重复组的数量。输出应该等于A=2 B=1

我不知道如何做到这一点:(

4

4 回答 4

3

只需使用count()

select producer, count(distinct type)
from yourtable
group by producer
于 2013-06-10T15:27:43.043 回答
1

尝试这个:

 select producer, count(distinct type) from table group by  producer
于 2013-06-10T15:28:06.917 回答
1

这样的事情应该可以解决问题:

SELECT producer, COUNT(DISTINCT type)
FROM YOUR_TABLE
GROUP BY producer

这应该会给你类似的结果:

producer  COUNT(DISTINCT type)
--------  --------------------
A         2
B         1
于 2013-06-10T15:31:11.990 回答
0
SELECT producer, COUNT(producer)
FROM table
GROUP BY producer, type
于 2013-06-10T15:28:15.590 回答