Вывести количество пользователей из России, задавших свой первый вопрос с тегом “sql” в октябре 2015

0

Please login or register to vote for this query.

(click on this box to dismiss)

Lifehacks

Q&A for people looking to bypass life's everyday problems with simple tricks

select count(*) from posts as p 
inner join users as u on u.id = p.ownerUserId  
where PostTypeId = 1 
and year(p.CreationDate) = 2015 and month(p.CreationDate) = 10 
and lower(u.location) like '%russia%'
and p.id = (select TOP 1 id from posts as po where po.OwnerUserId = u.id and po.PostTypeId = 1 
and year(po.CreationDate) = 2015 and month(po.CreationDate) = 10 
and lower(u.location) like '%russia%'
order by p.CreationDate ASC)
having count(case when p.tags like '%<sql>%' then 1 end) > 0;

Enter Parameters

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