test

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow en español

Preguntas y respuestas para programadores y profesionales de la informática

WITH UCountry AS (
  SELECT UserId, 
         Country,  
         Reputation
  FROM(
    SELECT Reputation,
           Id AS UserId, 
         CASE
                WHEN LOWER(Location) LIKE '%united kingdom%' THEN 'United Kingdom'
                WHEN UPPER(Location) LIKE '%UNITED STATES%' THEN 'United States'
                WHEN LOWER(Location) LIKE '%india%'  THEN 'India'
          ELSE 'Unknown'
         END AS Country
      FROM Users
      WHERE Reputation > 1
      AND LEN(Location) > 2
    ) AS MyTable
)
SELECT Country,
         SUM(Reputation) AS Repu
      FROM UCountry
GROUP BY Country
ORDER BY SUM(Reputation) DESC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results