Hello SQL

0

Please login or register to vote for this query.

(click on this box to dismiss)

Craft CMS Meta

Q&A about the site for administrators, end users, developers and designers for Craft CMS

-- select users coming from India,China and USA --
-- after checking the logical model, the user table has all information we need--
/*select *
from Users
where Location like '%China%' 
  OR 
  Location like '%India%' 
  OR 
  Location like '%USA%'
  */
  
--rewrite by using case then --
/*select Id, Location, 'country coming from'=
case when Location like '%India%' then 'coming from India'
      when Location like '%China%' then 'coming from China'
      when Location like '%USA%' then 'coming from USA'
      when Location is null then 'no location information'
      else 'coming from other counties'
      end 
from Users
*/

--generte a frequency table for reputation --
select count(Id) as 'count',Reputation
from Users
group by Reputation

Enter Parameters

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