Created
September 7, 2018 16:04
-
-
Save Nex-Otaku/e7ed8e61e6607895de69bdb8c98db865 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
count(*) as follower_count, | |
c1.created_at, | |
c1.vk_name, | |
concat('https://vk.com/club', c1.vk_id) AS url | |
from follower | |
inner join follower_club on follower_club.follower_id=follower.id | |
inner join club c1 on follower_club.club_id=c1.id | |
where exists( | |
select * from message | |
inner join stage on message.stage_id=stage.id | |
inner join funnel on stage.funnel_id=funnel.id | |
inner join club c2 on funnel.club_id=c2.id | |
where | |
(funnel.deleted=0) | |
and (stage.deleted=0) | |
and (c2.deleted=0) | |
and (c2.id=c1.id) | |
and (message.follower_id=follower.id) | |
) | |
group by c1.id | |
order by follower_count DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment