如何选择不同并计算所选的?这是我选择Distinct的代码:
SELECT distinct [ClientID]
,[AssessmentDate]
FROM [dbo].[UserAssessrcads]
我希望它以:
结束RCADS 62
(或类似的东西)
答案 0 :(得分:2)
你可以使用dinamic table
select count(*) from (
SELECT distinct [ClientID]
,[AssessmentDate]
FROM [dbo].[UserAssessrcads] ) t
答案 1 :(得分:2)
更好的方法是:
SELECT [ClientID],[AssessmentDate], count(1)
FROM [dbo].[UserAssessrcads]
group by [ClientID],[AssessmentDate]