mysql - How do I count number of different types of things in a SQL table? -


i have table storing set of transactions

customer | flavor | date purchased | location | blah | blah anna     | apple  | 2014-01-01     | seattle  | 1    | 0 anna     | grape  | 2014-01-01     | seattle  | 1    | 0 ... 

i'd able select number of different flavors each customer tried.

like...

who   | number of flavors tried anna  | 4 beth  | 1 cathy | 100 

and it's bending brain knot. how group/join/? way victory?

if group customer aggregate functions count() applied every single group , not complete resultset.

distinct counts different flavors.

select customer,         count(distinct flavor) `number of flavors tried` your_table group customer 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -