Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Count Distinct Over Partition Syntax Error

$
0
0
Count(Distinct [field]) over (partition by [field2]) returns a syntax error at the key word distinct

Count(all [field]) over (partition by [field2]) compiles fine

I am writing a query to count the number of clients a sales rep has when the sales rep represents multiple companies (ad agency).  I need a count of the clients each company has and a distinct count that each rep has.  A client may be assigned to multiple companies.

Is a distinct count supported with partitions?



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>