V
V
Vladislav2021-11-24 18:01:44
MySQL
Vladislav, 2021-11-24 18:01:44

What is the best way to make a selection?

619e52f191884560752334.png
Guys, tell me how to correctly compose a query in order to get such an output table, is it possible to do this with one query like that.

I have a table where answers are stored and people from different groups answer them.
Let's say: a person chose answer 1 and he is in group 3, and the other one chose answer 2 and he is also in group 3.
How best to make a query so that I get a column with all id groups and three columns with the number of selected answers.

Let's say: group 3: number one answers selected: 33 people. Number two: 12 people and Number three: 2 people
And so on for all groups.
In fact, the final table will always consist of 4 columns (group id and 3 answers) and 7 (total 7 groups) rows

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question