Stackoverflow Users Count Distribution in the World By Country

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow em Português

Perguntas e respostas para programadores profissionais e entusiastas

-- Stackoverflow Users Count Distribution in World By Country 
-- Created by Mehrdad Dowlatabadi (stackoverflow.com/users/9714791/mehrdad-dowlatabadi)

SELECT 
ROW_NUMBER() OVER(ORDER BY  count(*) DESC) Rank,
UPPER(TRIM( IIF(CHARINDEX(',', Reverse(Location))> 0, Reverse(SUBSTRING(Reverse(Location),1,CHARINDEX(',', Reverse(Location))-1)), Location))) as Country,
count(*) as UsersCount,
cast(round(CAST((100*count(*)) AS float) / CAST((select count(*) FROM Users Where Reputation>##MinReputation##) AS float),2) as numeric(36,2)) as UsersPercent
FROM
    Users
Where 
    Reputation>##MinReputation##
Group By    
    UPPER(TRIM( IIF(CHARINDEX(',', Reverse(Location))> 0, Reverse(SUBSTRING(Reverse(Location),1,CHARINDEX(',', Reverse(Location))-1)), Location)))
Having 
    count(*)>=##MinCountryUsers##
Order By 
    count(*) DESC

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results