Query of SQL Count

Asked

Viewed 43 times

-2

In a certain algorithm routine, the following data is recorded in a table:

Color Changed Led (Are two possible leds, code 2 to yellow, 3 to red) Reason for the Change (These are pre-defined reasons registered that the user selects at the time of the change)

below a table print

inserir a descrição da imagem aqui

what I need is to make a query that returns 2 columns of COUNT, one for each led (leds 2 and 3), grouped by reason.

more or less in this format:

nomeMotivo    | qtdAmarelo | qtdVermelho

Missing Tiles | 2 | 1
Maintenance | 3 | 2

In short, I need to know how many times each led was triggered in each motif

  • Search by PIVOT https://stackoverflow.com/questions/3561881/mysql-pivot-counting

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.