SELECT Users.Id, COUNT(Badges.Id) AS badge_count FROM ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Woodworking

Q&A for professional and amateur woodworkers

--SELECT TOP 100 *
--FROM Users
--WHERE LOWER(Location) LIKE '%latvia%'

--SELECT Location, COUNT(Id) loc_count
--FROM Users
--WHERE LOWER(Location) LIKE '%latvia%' OR Location LIKE '%Riga %' OR Location LIKE '%Rīga %' OR Location LIKE '%Riga,%'
--GROUP BY Location
--ORDER BY loc_count DESC

--WITH valid_users AS
--(SELECT 

SELECT 
Users.Id, COUNT(Badges.Id) AS badge_count
FROM 
    Users
INNER JOIN 
    Badges
ON 
Users.Id = Badges.UserId
WHERE 
    LOWER(Location) LIKE '%latvia%' OR Location LIKE '%Riga %' OR Location LIKE '%Rīga %' OR Location LIKE '%Riga,%'
GROUP BY 
    Users.Id
--ORDER BY badge_count DESC
HAVING 
    COUNT(Badges.Id) > 100;

Enter Parameters

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