HelloSQL

0

Please login or register to vote for this query.

(click on this box to dismiss)

Genealogy and Family History Meta

Q&A about the site for expert genealogists and people interested in genealogy or family history

-- select users cominf from India, China, 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'
      when Location id null then 'No location information'
      else 'Coming from other countries'
      end 
from Users
*/

-- generate a frequency distribution tabel for reputaion (x axis) (count=y axis) --
/*select count(Id) as 'CountReputation', Reputation /*as = alias name for the column*/
from Users 
group by Reputation 
having Reputation > 100 
order by Reputation desc 
*/

-- finding users whose Reputation is above average --
select avg (Reputation)
from Users

Enter Parameters

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