The query below returns all of different subscriptions a user has. In another column, I would like to return the count of how many times a given subscription occurs. Any advice on how do this?
I tried including
COUNT(GROUP_CONCAT(subscription_plan_id))
but it doesn't work.
SELECT GROUP_CONCAT(subscription_plan_id)
FROM
subscriptions
WHERE
created_at BETWEEN '2014-01-01' AND '2014-01-31'
GROUP BY
user_id
HAVING
COUNT(subscription_plan_id) > 1
Desired output:
group_concat...count
1,2,3...2
2,3...5
2,3result in5as the count? Please show the input data and the desired output. Best would be to make a sqlfiddle.