mysql - SQL Query to find exclusive customer -


i have table 2 columns cust , category,

**cust   category**     1         x    2         y    1         y    2         z    3         x    4         d 

customer 1 has purchased category x , y, 'category x', 3 exclusive customer since cust 3 purchased x. want result below 3 columns (category, no of customer purchased in category , exclusive customer):

**category  noofcust  exclusivecust**      x         2              3     y         2             null     z         1             null     d         1              4  

how can query table result?

used temp table duplicate structure:

select      category,      count(*) noofcust,      case when count(*) = 1 max(id_w) else null end exclusive #worker t group category 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -