Skip to content

Instantly share code, notes, and snippets.

@yehosef yehosef/test.sql
Created Jun 20, 2016

Embed
What would you like to do?
set @sum=0;
select mea1_count, num_members, @sum:=@sum+num_members from (
SELECT
mea1_count,
count(mem_id) num_members
FROM (
SELECT
mea1.mem_id,
count(mea1.id) mea1_count
FROM member_email_actions mea1
WHERE mea1.open_date BETWEEN '2016-05-02' AND '2016-05-09'
AND mea1.mem_id IN (
SELECT m.id
FROM member m
WHERE date(m.activated_at) = '2016-05-01'
)
GROUP BY mea1.mem_id
) AS x
GROUP BY mea1_count
ORDER BY mea1_count DESC
) y
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.