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.
如何进行计数不同的选择?基本上我有所有这些费用,我只想计算涉及该费用的不同员工的数量。(我已经有分组依据的其他字段)
SELECT COUNT(DISTINCT employeeid) FROM ....
简单如:select count(distinct(field)) from table
select count(distinct(field)) from table
现场样本:http ://sqlfiddle.com/#!3/81379/2/3
您可以将 aDISTINCT放入COUNT(在 TSQL 中):
DISTINCT
COUNT
SELECT COUNT(DISTINCT(employee)) ...