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

Popular posts from this blog

c++ - Do gcc's __float128 floating point numbers take the current rounding mode into account? -

java - the value of local variable is not used -