Skip to content
Advertisement

Create category column mysql

I have a transactions table,

I want to query it using MySQL 5.7 group by vendor and count number of transaction, and categorize vendor by these criteria

  1. Great: More than 2 SHIPPED and 0 CANCELLED transactions
  2. OK: More than 2 SHIPPED and 1 or more CANCELLED transactions
  3. Mediocre: other than Superb and Good criteria

result should be like this,

Advertisement

Answer

This is a case expression in an aggregation query:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement