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 logical model, the user table has all the info 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'
     else 'coming from other countries'
     end
from Users*/

-- generate a frequency table for reputation--
select count(Id) as 'ReputationCount', Reputation from Users
group by Reputation
having Reputation > 100 
order by Reputation desc

Enter Parameters

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