hi

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- 1: How many users didn’t complete their personal information? --
-- (only consider website url and location) --

/*
select count(Id) as User_Count
from Users
where WebsiteUrl = ''
or Location = ''
*/


-- 2: How many users didn’t post any questions in year 2015 -- 
-- (hint: use PostType table to check which post types is question) --


/*
select *
from PostTypes
where Name != 'Question'
*/

/*
select count(distinct(Id)) as Users_Count
from Users
where CreationDate between '2015-01-01 00:00:00' and '2016-01-01 00:00:00'
*/

/*
select count(distinct(OwnerUserId))
from Posts
where CreationDate between '2015-01-01 00:00:00' and '2016-01-01 00:00:00'
and PostTypeId = '1'
*/


-- 3. How many post titles related to ‘sports’ without any accepted answer? --
/*
select count(Id) as Title_Count
from Posts
where Title like '%sports%'
and AcceptedAnswerId is null
*/


-- 4. The user who created the most viewed posts in year 2023 --
-- What kind of badges does he/she own? --
/*
select OwnerUserId
from Posts
where ViewCount = (select Top 1 ViewCount
                    from Posts
                    order by ViewCount desc)
and CreationDate between '2023-01-01 00:00:00' and '2024-01-01 00:00:00'
*/

/*
select top 1 ViewCount, OwnerUserId
from Posts
where CreationDate between '2023-01-01 00:00:00' and '2024-01-01 00:00:00'
order by ViewCount desc
*/

/*
select Class
from Badges
where UserId = '17532318'
and Date between '2023-01-01 00:00:00' and '2024-01-01 00:00:00'
*/


-- 5. How many posts are voted as spam? --
select *
from VoteTypes
Where Name = 'Spam'

Enter Parameters

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