0

I would like that data as in table below:

Failed | Passed
1         1

Instead having this column header names i would like to change it to, and is this possible?

Status | Count
Failed    1
Passed    1
Shadow
  • 33,525
  • 10
  • 51
  • 64
loki2013
  • 1
  • 1
  • 2
    Possible duplicate of [MySQL pivot row into dynamic number of columns](http://stackoverflow.com/questions/12004603/mysql-pivot-row-into-dynamic-number-of-columns) – Shadow Mar 23 '17 at 11:19
  • This is called pivot table. The duplicate topic describes both static (number of columns is know in advance) and dynamic pivoting (number of columns not know in advance). – Shadow Mar 23 '17 at 11:20

1 Answers1

0

Instead of COUNT use SUM to sum over the values you need, like the folowing

SELECT SUM(status='Failed') as failed, SUM(status='Passed') 
FROM table_with_status

This works because when you write status='Failed' it returns 1 if status is failed, and otherwise it returns zero

user1898027
  • 330
  • 2
  • 13