比如有表 A 中字段 B,B的值为:
1
1
2
2
3
那么我希望得到不同值的个数为3,也不知我说明白没有。:)
---------------------------------------------------------------
select count(B) from (select distinct B from A)
---------------------------------------------------------------
SELECT COUNT(B) AS X FROM (SELECT DISTINCT B FROM A) DERIVEDTBL
X就是你想要得!
---------------------------------------------------------------
select count(distinct(b)) from a