Hello SQL


Please login or register to vote for this query.

(click on this box to dismiss)

Bicycles Meta

Q&A about the site for people who build and repair bicycles, people who train cycling, or commute on bicycles

--- 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' 
  Location like '%India%' 
  Location like 'USA'

/*---rewrite by using case then---
select Id, Location, 'country coming from' =
case when Location like '%India%' then 'coming form India'
     when Location like '%China%' then 'coming form China'
     when Location like '%USA%' then 'coming form USA'
     when Location is null then 'no location Information'
     else 'coming from other countries'
from users

/*--generate a frequency table for reputation--
select count(Id) as 'count', Reputation
from Users
group by Reputation
having countReputation >100 and countReputation <200
order by Reputation desc

--find users whose reputation are above average--
--first step: find average reputation
select avg(Reputation)
from Users
--second step: find the users who's reputation are above average--
select Id
from Users
where Reputation > 95
--rewrite in nest SQL--
select Id 
from Users
where Reputation > (select avg(Reputation) 
                    from Users
                    where CreationDate > (select )

--find the posts the user who has gold bages and created their account in --
from Posts
full join Users
on Posts.OwnerUserId = User.Id
where Users.CreationDate > '2024-01-01 00:00:00' 
and Badges.Class > 1

select distinct class from badges

Enter Parameters

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