ля каждого года посчитать процент пользователей из России, задающих вопросы

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

select year(p.creationdate) as ' year ',
--count(case when pt.id = 2  then 2 end) as 'count of answers',
count(distinct u.id) as 'count of users ',
count(p.id) as 'count of posts',
count(distinct (case when u.location like '%Ru%' then u.id end)) as 'count of users from Ru'
, round(cast (count(distinct (case when u.location like '%Ru%' then u.id end)) as float)*100/count(distinct u.id), 3) 'percent, %'
from users u
join posts p on p.owneruserid = u.id
join posttypes pt on pt.id = p.posttypeid
where pt.id = 1
group by year(p.creationdate)
order by year(p.creationdate) desc

Enter Parameters

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