Is there an equivalent to 1/countif in SQL Server?
Something like:
SELECT ID,1/COUNTIF(ID)
FROM Table
…that divides 1 by the number of rows with a certain ID in Table, returning the results in this format:
ID Result
1 0.5
1 0.5
2 1
3 0.33
3 0.33
3 0.33 etc.
If your version is 2005 and newer, you can use
OVERwith the aggregateCOUNT():You can find more examples in the MSDN site:
OVERclause.