0
A
回答
6
因爲這就是group by
的工作原理。它爲源數據中每個標識的行組返回一行。在這種情況下,它會給出每個組的計數。
爲了得到你想要的東西:
select count(distinct column)
from table;
編輯:
作爲一個稍微注意,如果column
可以NULL
,那麼真正的等價物是:
select (count(distinct column) +
max(case when column is null then 1 else 0 end)
)
from table;
2
試試這個:
SELECT COUNT(*), column
FROM table
GROUP BY column
相關問題
- 1. SQL COUNT * GROUP BY大於,
- 2. SQL Group By By By By Count
- 3. SQL group by count其中count大於
- 4. GROUP BY的COUNT(*)
- 5. MySQL count group by
- 6. Python Group by count
- 7. MySQL COUNT(*)GROUP BY HANDING COUNT =?
- 8. Mysql COUNT,GROUP BY和ORDER BY
- 9. Group by by mongoDb without count
- 10. SELECT COUNT,GROUP BY,ORDER BY
- 11. sql count/group by/zero
- 12. MYSQL GROUP BY和COUNT
- 13. MySQL GROUP BY和COUNT
- 14. SQL Count()和GROUP BY
- 15. COUNT和GROUP BY SQL
- 16. MySQL Group By Count Substring
- 17. linq,group by和count
- 18. COUNT DISTINCT與GROUP BY
- 19. Linq-select group by&count
- 20. Rails的GROUP BY,COUNT
- 21. NHIbernate Linq group by count
- 22. COUNT DISTINCT + COUNT GROUP BY HAVING(值)+ GROUP BY個月
- 23. Rx等同於GROUP BY的COUNT?
- 24. Django group by to find count
- 25. Count(Distinct x)and Group By y
- 26. cakephp 3.0 + group by + count + paginate
- 27. COUNT,GROUP BY,INNER JOIN,php,mysql
- 28. MYSQL GROUP BY/COUNT條件
- 29. activerecord group by count和user_id
- 30. GROUP BY與COUNT條件
適合我。什麼是實際查詢? –
@CL。它是否適合你使用sqlite? –
顯然我誤解了描述。 –