Q&A for SharePoint enthusiasts
-- Benford's law on SO SELECT firstDigit, COUNT(*) [Count], convert(decimal(5,2),100.0*COUNT(*)/SUM(COUNT(*)) OVER ()) Percentage, Benford.p Law FROM ( SELECT LEFT(LEN(post.Body),1) as firstDigit FROM Posts as post ) [ ] inner join ( values (1, 30.1), (2, 17.6), (3, 12.5), (4, 9.7), (5, 7.9), (6, 6.7), (7, 5.8), (8, 5.1), (9, 4.6) ) Benford(d,p) on Benford.d = [ ].firstDigit GROUP BY firstDigit, Benford.p Order by firstDigit