Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法获取某个字段的每个不同值的计数?
for name in (SELECT DISTINCT name FROM table) SELECT COUNT name FROM table
不使用光标
您可以使用COUNT()-- 聚合函数。
COUNT()
SELECT Name, COUNT(*) totalCount FROM tableName GROUP BY Name