Q&A about the site for Ubuntu users and developers
/* select * from Users where Location like '%China%' OR Location like '%USA%' OR Location like '%Pakistan%' */ /* rewrite by using case then */ /* select Id,Location, 'country coming from'= case when Location like '%China%'then 'coming from China' when Location like '%USA%'then 'coming from USA' when Location like '%Pakistan%'then 'coming from Pakistan' else 'coming from elsewhere' end from users */ -- generate frequency distribution table-- /*select count(Id) as 'count' ,Reputation from Users group by Reputation having Reputation > 100 order by Reputation desc */ --select users whos reputation are above averages-- /*select avg(Reputation) from Users */ -- second step: find the users who's reputations are above average-- /*select Id from Users where Reputation > 88 */ -- rewrite in nest SQl -- /*select Id from Users where Reputation > (select avg(Reputation) from Users where CreationDate >(select) )*/ --find the posts the users who has gold badges and created their account in 2024 select * from Posts left join Users on Posts.OwnerUserId = Users.Id where Users.CreationDate > '2024-01-01 00:00:00'