SQl - select columns and group them -
i have table below , need result when run query
results
title | count ---------------- foo | 3 bar | 2 table
customer_id | title ------------------- 55 | foo 22 | foo 55 | bar <-- duplicate 23 | bar 55 | bar <-- duplicate 23 | foo update thank quick response!
the trick count distinct customer ids, won't count double foo customer 55.
if need to, can order results count too, or can leave out order by clause.
select title, count(distinct customerid) `count` yourtable group title order `count` desc
Comments
Post a Comment